# Calculate angle of a line at the point it intersects a circle

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

-
I'm pretty sure this was asked before, but I can't find the other question. –  Ｊ. Ｍ. Sep 9 '11 at 1:23
@J.M. - This one: math.stackexchange.com/questions/59/…? –  Peter Sep 9 '11 at 3:44
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.
Actually, once s/he has $(a - x_1, b - y_1)$, two-argument arctangent can then be used to get the answer. –  Ｊ. Ｍ. Sep 9 '11 at 1:30