Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

geometry

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 hereenter image description here

like image 894
Kyle Anderson Avatar asked Dec 31 '12 00:12

Kyle Anderson


People also ask

How do you find the coordinates when given the radius and angle?

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‎°)).

How do you find the equation of a circle with the center and radius?

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.

How do you find a point on the unit circle given an angle?

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.


1 Answers

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)) 
like image 77
yoozer8 Avatar answered Sep 19 '22 18:09

yoozer8