1
$\begingroup$

Given a line with end points $(x_1,y_1)$ $(x_2,y_2)$ and a circle centered at $(x_1,y_1)$ how do I calculate the angle of the line (in degrees) as it relates to the circle? If that doesn't make sense then please see my basic example below.

For the below examples I'm assuming $(x_1,y_1)$ is $(0,0)$ and the circle has a radius of 1.

$(x_2,y_2)$ -- (in degrees)

$(2,0)$ -- 0
$(0,2)$ -- 90
$(-2,0)$ -- 180
$(0,-2)$ -- 270

$\endgroup$
3
$\begingroup$

It seems to me that you are just finding the angle of the line from the point to the center of the circle, with 0 indicating that the line is parallel to the positive x axis. In this case, you should always just move your circle to the origin and then calculate the angle with the positive x axis.

For example, suppose that your center is at $(x_1, y_1)$ and you want to calculate the angle wrt the right horizontal from the center of the circle of the point $(a,b)$. Then you pretend your circle is at the origin by finding the angle between $(a - x_1, b - y_1)$ and the positive x axis.

I will assume that you can do that - I would recommend drawing a right triangle, or using the dot product and inverse cosine.

$\endgroup$
  • 1
    $\begingroup$ Actually, once s/he has $(a - x_1, b - y_1)$, two-argument arctangent can then be used to get the answer. $\endgroup$ – J. M. is a poor mathematician Sep 9 '11 at 1:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.