Results 1 to 10 of 10

Thread: Find points around circle.

  1. #1
    Join Date
    Oct 2007
    Location
    http://ushort.us/oqmd65
    Posts
    2,605
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default Find points around circle.

    I have this

    And lets keep the middle point at 10,10. How would I find all the cords around the circle.

    Thanks.

    (I'll rep!, then I can rep frement!)
    I do visit every 2-6 months

  2. #2
    Join Date
    Jul 2008
    Location
    England
    Posts
    763
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Get the radius of the circle, then use trig to work the rest out.
    lol

  3. #3
    Join Date
    Nov 2007
    Location
    46696E6C616E64
    Posts
    3,069
    Mentioned
    44 Post(s)
    Quoted
    302 Post(s)

    Default

    Hmmh, get the white points to TPA then use ReturnPointsNotInTPA to get the points not in TPA and then get the closest ones near the middle point

    EDIT: Oh this was in math
    Last edited by Frement; 04-17-2010 at 07:50 PM.
    There used to be something meaningful here.

  4. #4
    Join Date
    Oct 2007
    Location
    http://ushort.us/oqmd65
    Posts
    2,605
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Thanks i guess quick, and I still cant rep frem
    I do visit every 2-6 months

  5. #5
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    If this was purely for maths, I would use trig ratios.
    Make a loop and assign each point to an array of points around the circumference.
    EDIT:
    Actually Coded it:

    SCAR Code:
    program New;
    {.Include SRL/SRL.Scar}
    {.Include SRL/SRL/Misc/Debug.Scar}
    {.Include SRL/SRL/Misc/Users.Scar}

    Var X, Y, I: Integer;
        TPA : TPointArray;
        ATPA : T2DPointArray;
        TP : TPoint;
        TB : TBox;

    Function GenerateCircumferencePoints(MidX, MidY : Integer; SDeg, EDeg, Radius : Integer) : TPointArray;
    Var I, II : Integer;
    Begin
      For I := SDeg To EDeg Do
      Begin
        Inc(II);
        SetLength(Result, II);
        Result[II - 1] := Point(Round(Sin(Radians(I)) * Radius + MidX), Round(Cos(Radians(I)) * Radius + MidY));
      End;
    End;

    Begin
      SetupSRL;
      SRLPlayerForm(False, [], [], [], []);
      DebugTPA(GenerateCircumferencePoints(10, 10, 0, 360, 7), '');
    End.
    Last edited by Naum; 04-18-2010 at 11:59 AM.

  6. #6
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Now that the circle is so small this should suffice:
    SCAR Code:
    for x:= 0 to 19 do
      for y := 0 to 19 do
        if InCircle(x, y, 10, 10, 10) then
        begin
          inc(L);
          SetLength(Result, L);
          Result[L - 1] := Point(x, y);
        end;

  7. #7
    Join Date
    Oct 2007
    Location
    http://ushort.us/oqmd65
    Posts
    2,605
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Marpis, that gets the same size circle drawn, as there is nothing to use radius and such.

    And naum, I was about to scratch the circle part of the project until yours worked! Thank you! Rep!
    I do visit every 2-6 months

  8. #8
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    Nice to see it worked.
    If it was just for that smiley, then a faster way would be to do a 'FindColors' on the white part of his face. Then use GetTPAEdges and store the points ; instead of using mine which lags by loops.

  9. #9
    Join Date
    Oct 2007
    Location
    http://ushort.us/oqmd65
    Posts
    2,605
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    I just need the output points once, as the smiley will be moving from the center point around, so the points will be moving with it using offsets.
    I do visit every 2-6 months

  10. #10
    Join Date
    Dec 2006
    Location
    Houston, TX USA
    Posts
    4,791
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Would be faster and simpilier (coding and runtime) to use Wizzyplugin.

    SCAR Code:
    program Circle;

    {.Include SRL\SRL.SCAR}
    {.Include SRL\SRL\Misc\DeBug.SCAR}

    var
      TPA: TPointArray;

    begin
      {TPA := TPAFromBox(IntToBox(X1, Y1, X2, Y2));
      FilterPointsPie(TPA, 0, 360, Radius, Radius + 1, OriginX, OriginY);}

     
      TPA := TPAFromBox(IntToBox(50, 50, 100, 100));
      FilterPointsPie(TPA, 0, 360, 25, 26, 75, 75);
     
      DeBugTPA(TPA, '');
    end.

    And lol... why not just use distance anyways?

    SCAR Code:
    program Circle;

    {.Include SRL\SRL.SCAR}
    {.Include SRL\SRL\Misc\DeBug.SCAR}

    var
      OldTPA, NewTPA: TPointArray;
      I, C: LongInt;

    begin
      OldTPA := TPAFromBox(IntToBox(50, 50, 100, 100));
      for I := 0 to High(OldTPA) do
        if (Distance(OldTPA[I].X, OldTPA[I].Y, 75, 75) = 25) then
        begin
          SetLength(NewTPA, C + 1);
          NewTPA[C] := OldTPA[I];
          Inc(C);
        end;
      DeBugTPA(NewTPA, '');
    end.

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
  •