Results 1 to 8 of 8

Thread: Creating a circle outline TPA

  1. #1
    Join Date
    Jan 2008
    Location
    Frankfurt, Germany
    Posts
    742
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Creating a circle outline TPA

    What formula (or function, if it exists) do I have to use in order to "shape" a TPA into the outline of a circle, so that "DebugTPA" would return a circle outline with the desired radius... I am pretty damn sure we have had that in math, most likely during the "radian measure" topic, but I am having a black-out atm...
    Thanks a lot,
    Pure1993
    There is nothing right in my left brain and there is nothing left in my right brain.

  2. #2
    Join Date
    Dec 2006
    Location
    Copy pastin to my C#
    Posts
    3,788
    Mentioned
    8 Post(s)
    Quoted
    29 Post(s)

    Default

    Explain again what do you want, do you want to create a minimal circle around the TPA?

    If so, GetTPABounds, then Distance(Box.x1, Box.y1, Box.x3, Box.y3), then for loop 0 to 359 doing X := ((Box.x1 + Box.x2) shr 1) + Round(radius (<- the distance we got earlier) * cos(radians(i (<- the angle which is the looping int))));

    and Y := ((Box.y1 + Box.y2) shr 1) + Round(radius * sin (radians(i)));

    Then add them to TPA or shit. CBF to make the function for you, but that should help you do it...
    Last edited by n3ss3s; 05-16-2009 at 12:53 AM.

  3. #3
    Join Date
    Feb 2007
    Location
    PA, USA
    Posts
    5,240
    Mentioned
    36 Post(s)
    Quoted
    496 Post(s)

    Default

    you mean FilterPointsPie???

  4. #4
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    SCAR Code:
    function CreateCircleTPA(origin: TPoint; radius: Integer; step: Extended): TPointArray;
    var
      a: Extended;
      l: Integer;
    begin
      a := -step;
      l := -1;
      while (a < 360 - step) do
      begin
        l := l + 1;
        a := a + step;
        SetLength(Result, l + 1);
        Result[l].x := origin.x + Round(Cos(Radians(a)) * radius);
        Result[l].y := origin.y + Round(Sin(Radians(a)) * radius);
        if (l = 0) then
          Continue;
        if ((Result[l].x = Result[l - 1].x) and (Result[l].y = Result[l - 1].y)) then
          l := l - 1;
      end;
    end;

    Lower step = higher accuracy, but really 1 works fine. Probably a better method for filtering duplicate TPoint's in an array (sure there was a function for it, but too lazy to trawl through functions for it).
    n3ss3s's method would also work, but being able to set a step is useful for larger circles as 1 degrees accuracy can be quite fail if it's rather big
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

  5. #5
    Join Date
    Jan 2008
    Location
    Frankfurt, Germany
    Posts
    742
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    YAY! Mixster = GOD! Thanks mate

    Also thanks to you n3ss3s and you footballjds! It's jsut that mixster put it into a nice little function which I can easily read through to understand.
    There is nothing right in my left brain and there is nothing left in my right brain.

  6. #6
    Join Date
    Dec 2006
    Location
    Copy pastin to my C#
    Posts
    3,788
    Mentioned
    8 Post(s)
    Quoted
    29 Post(s)

    Default

    mixster, I didn't mean what you wrote... I thought he wanted to create a "minimal" circle around the TPA...

    Pure1993, to find that out all you would have needed to do is read mine or Zephyr's trig tut

  7. #7
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    I was thinking it referred to getting the TPA bounds for the area you wanted the circle to cover
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

  8. #8
    Join Date
    Jan 2008
    Location
    Frankfurt, Germany
    Posts
    742
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    @N3ss3s: There are always two problems when I post questions:
    1.) I don't how to solve, or how the solution could look like (of course, this time, I had a rough idea, but this was an exception), and that is why I am not able to use the search function when looking for answers 100% of the time.
    2.) It's always a question of using the right key words... I don't want to critize this site, but the search option is sorta terrible... :S


    ^ Anyway,this is what it should originally look like, the pointed circle is even better though ^
    There is nothing right in my left brain and there is nothing left in my right brain.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •