Results 1 to 17 of 17

Thread: Coords of a point in a circle...

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

    Default Coords of a point in a circle...

    This is nothing big, but even more useful.

    Having troubles with remembering all the 'Round(Radius * Sine(x)) + MidPointX' Etc?

    Heres the answer for your problems:

    SCAR Code:
    Function PointOnCircle(MidX, MidY, Radius, Angle: Integer): TPoint;
    Begin
      Result.x := MidX + Round(Radius * Cos(Radians(Angle - 90)));
      Result.y := MidY + Round(Radius * Sin(Radians(Angle - 90)));
    End;

    MidX, MidY - Coords of the midpoint
    Radius - Distance between the midpoint and the point you wanna get
    Angle - angle to get the point of.

    Also, that does not need SRL, I wanted to find out the 'real' way...

    Free to use, though crediting is nice even this isnt anything big..

  2. #2
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Isn't there something similar to this inbuilt into scar. All it does is converts Polar coords to cartesian.

    EDIT: Actually nevermind. The ones in the SCAR manual don't serve the same purpose.

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

    Default

    I have no idea what Polar and Cartesian are...

  4. #4
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    They are ways of specifying a point on a plane. Cartesian coords are x and y while polar coords are distance from an origin (radius) and angle.

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

    Default

    ookay... I think I got it.

  6. #6
    Join Date
    Jul 2007
    Location
    Ottawa, Canada
    Posts
    930
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Ooooh that brings back memories of grade 12 geometry and algebra...

    Nice thing you have there.. could be useful for taking compass angle and walking a distance in a direction.
    ~ Metagen

  7. #7
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    Next step:

    SCAR Code:
    Function InDegreeAndDist(x, y, mx, my, sd, ed: Integer; minr, maxr: Extended): Boolean;

    Var
       xDeg, d: Extended;

    Begin
      xDeg := Degrees(ArcTan2(y - my, x - mx)) + 90;
      If xDeg < 0 Then
        xDeg := 90 - (xDeg * -1) + 270;
      Result := ( (xDeg >= sd) And (xDeg <= ed) );
      If Result Then
      Begin
         d := Sqrt(Sqr(x - mx) + Sqr(y - my));
         Result := ( (d >= minr) And (d <= maxr) );
      End;
    End;




    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

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

    Default

    Hehe, I know what it does by the name, but can you tell more specifically what it does?

    Tan = b/a, rite?

    So ArcTan... ArcTan2...

    SHARE YOUR WISDOM GOD DAMIT!

    Btw, I have a same like function, though how it works is simplier, but does the job though:

    SCAR Code:
    Function InPizzaSlice(xx, yy, StartR, EndR, MidX, MidY, MaxRadius: Integer): Boolean;
    var
      Rx, Ry, Dx, Dy, D: Integer;
    Begin
      Rx := Round( MaxRadius * Sine(StartR)) + MidX;
      Ry := Round(- MaxRadius * Cose(StartR)) + MidY;
      Dx := Round( MaxRadius * Sine(EndR)) + MidX;
      Dy := Round(- MaxRadius * Cose(EndR)) + MidY;
      If (XX > Rx) And (XX < Dx) Then
      Begin
        Result := (Distance(xx, yy, MidX, MidY) <= MaxRadius);
      End;
    End;



    But hey if not post, or make a tut, can you wizzy tell me about those ArcTans etc and where, how can they be used for effectively, like in your function..

  9. #9
    Join Date
    Dec 2006
    Location
    Banville
    Posts
    3,914
    Mentioned
    12 Post(s)
    Quoted
    98 Post(s)

    Default

    You mean n3ss3s is getting smarter?
    The jealous temper of mankind, ever more disposed to censure than
    to praise the work of others, has constantly made the pursuit of new
    methods and systems no less perilous than the search after unknown
    lands and seas.

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

    Default

    You mean n3ss3s is getting smarter?
    Nobody said Im not interested in maths?

    And I've knew the version of the function with SRL's Sine and Cose a long time though.... (RRW )

    And we talk about these things with my grandpa about every time we meet (today once again), and he is a theoretic physic so I can ask him about these things, and then I get an explanation that is more than enough, but even better

  11. #11
    Join Date
    Aug 2007
    Posts
    1,404
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Wizzup? View Post
    Next step:

    SCAR Code:
    Function InDegreeAndDist(x, y, mx, my, sd, ed: Integer; minr, maxr: Extended): Boolean;

    Var
       xDeg, d: Extended;

    Begin
      xDeg := Degrees(ArcTan2(y - my, x - mx)) + 90;
      If xDeg < 0 Then
        xDeg := 90 - (xDeg * -1) + 270;
      Result := ( (xDeg >= sd) And (xDeg <= ed) );
      If Result Then
      Begin
         d := Sqrt(Sqr(x - mx) + Sqr(y - my));
         Result := ( (d >= minr) And (d <= maxr) );
      End;
    End;

    Argh, you beat me to it :P

    As if! I don't get ANYTHING of that. ArcTan? Arctic Suntan? I just don't...

    -Knives

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

    Default

    Now I get it.... It wasnt spam... Wizzy wanted to show off his ArcTan2!

  13. #13
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    Heh, I just got back from 9 hours of school. Had a math exam of 2,5 hours.

    Tan = Sin / Cos;
    Tan = Slope;
    ArcSin(Sin(z)) = z;
    ArcCos(Cos(z)) = z;
    ArcTan(Tan(z)) = z;
    PHP Code:
    function ArcTan2(YXExtended): Extended;
    ArcTan2 calculates ArcTan(Y/X), and returns an angle in the correct quadrant.
    IN: |Y| < 2^64, |X| < 2^64<> 
    OUT
    : [-PI..PIradians 
    ArcTan(Delta Y, DeltaX) = 'Math' Degrees.
    Those degrees are from -180 To 180, that is why I called them 'Math' Degrees.
    You need to 'fix' them to make them like our Degrees.

    Then, if the degree is bigger than startDegree and lower than endDegree, it lies between those 2 degrees.
    Delta X = X1-X2.
    Square Root of (DeltaX^2 + DeltaY^2) = Distance.
    Use Distance (Sqrt(Sqr(X1-X2) + Sqr(Y1-Y2));
    Distance in 3d is:

    Sqaure Root of (DeltaX^2 + DeltaY^2 + DeltaZ^2)

    Is the distance >= minDistance and distance < maxDistance then
    return true.



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

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

    Default

    Had a math exam of 2,5 hours.
    Lol ridiculus amount of time for a test i have sympathy for you.

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

    Default

    ArcSin(Sin(z)) = z;
    ArcCos(Cos(z)) = z;
    ArcTan(Tan(z)) = z;
    But can you tell what they do? Im pretty sure their purpose isnt to return Cost(x)

  16. #16
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by n3ss3s View Post
    But can you tell what they do? Im pretty sure their purpose isnt to return Cost(x)
    Sin(x), Cos(x) and Tan(x) give the sine, cosine and tangent of an angle (in radians for the inbuilt scar functions). ArcSin, ArcCos, ArcTan are the inverse of sin, cos, and tan. ie they change the values back into angles. It a bit hard to explain unless you really want to go into the unit circle and into trigonometry. They basically help you find angles and lengths of sides and stuff when you're dealing with triangles.

    Quote Originally Posted by naumanakhlaq View Post
    Lol ridiculus amount of time for a test i have sympathy for you.
    I have a 3 hr and 10 min exam for each of my 6 subjects in about 2 weeks time.

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

    Default

    Ahh, the inversing means back to angles! Thanks.


    I have a 3 hr and 10 min exam for each of my 6 subjects in about 2 weeks time.
    Thanks for last tip, was nice to know you..

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Make a form with a special shape! Circle etc..
    By mastaraymond in forum OSR Advanced Scripting Tutorials
    Replies: 30
    Last Post: 06-02-2008, 04:58 PM
  2. [help] Moving mouse in a circle.
    By enig.ma in forum OSR Help
    Replies: 5
    Last Post: 12-26-2007, 02:37 PM

Posting Permissions

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