It's been 10 years since I did any math like this... I am programming a game in 2D and moving a player around. As I move the player around I am trying to calculate the point on a circle 200 pixels away from the player position given a positive OR negative angle(degree) between -360 to 360. The screen is 1280x720 with 0,0 being the center point of the screen. The player moves around this entire Cartesian coordinate system. The point I am trying trying to find can be off screen.
I tried the formulas on article Find the point with radius and angle but I don't believe I am understanding what "Angle" is because I am getting weird results when I pass Angle as -360 to 360 into a Cos(angle) or Sin(angle).
So for example I have...
What is the formula to return X on the circle?
What is the formula to return Y on the circle?
Typically, to find the x, y coordinates on a circle with a known radius and angle you could simply use the formula x = r(cos(degrees°)), y = r(sin(degrees°)).
To find the equation of a circle when you know the radius and centre, use the formula ( x − a ) 2 + ( y − b ) 2 = r 2 , where represents the centre of the circle, and is the radius.
Just remember that coordinates on the unit circle can be derived using: (x, y) = (cos A, sin A), where A is the measurement of the angle. In this case, A=4π3 . Now, you can plug in A into (cos A, sin A) to find the x and y coordinates of the answer.
The simple equations from your link give the X and Y coordinates of the point on the circle relative to the center of the circle.
X = r * cosine(angle) Y = r * sine(angle)
This tells you how far the point is offset from the center of the circle. Since you have the coordinates of the center (Cx, Cy), simply add the calculated offset.
The coordinates of the point on the circle are:
X = Cx + (r * cosine(angle)) Y = Cy + (r * sine(angle))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With