Find the point on a circle with given center point, radius, and degree

Kyle Anderson picture Kyle Anderson · Dec 31, 2012 · Viewed 77.6k times · Source

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...

  • 1280x720 on a Cartesian plane
  • Center Point (the position of player):
    • let x = a number between minimum -640 to maximum 640
    • let y = a number between minimum -360 to maximum 360
  • Radius of Circle around the player: let r always = 200
  • Angle: let a = a number given between -360 to 360 (allow negative to point downward or positive to point upward so -10 and 350 would give same answer)

What is the formula to return X on the circle?

What is the formula to return Y on the circle?

enter image description here enter image description here

Answer

yoozer8 picture yoozer8 · Dec 31, 2012

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))