Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|cite|improve this question
I'm pretty sure this was asked before, but I can't find the other question. – J. M. Sep 9 '11 at 1:23
@J.M. - This one:…? – Peter Sep 9 '11 at 3:44
up vote 3 down vote accepted

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.

share|cite|improve this answer
Actually, once s/he has $(a - x_1, b - y_1)$, two-argument arctangent can then be used to get the answer. – J. M. Sep 9 '11 at 1:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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