[Math] How to calculate angle given x,y coordinate

anglecoordinate systems

If I have a point say $(-8,-20)$, how can I calculate the angle. It should be a little under $270$ or a little over $-90$. However when I try this in google

atan(-20/-8) in degrees

it gives me $68.1985905$ degrees.

Does anyone know what's wrong?

Thanks

Best Answer

Given a particular value $a = \tan(x)$ there are two angles in the interval $(-\pi, \pi]$ or $[0, 2\pi)$ that have $a$ as their tangent. (See graph.)

To determine which angle, you'll need to look at which quadrant your point is in, and you can do this by inspection. Then, if you end up with an angle that doesn't make sense, you simply add or subtract $\pi$ to get it in the right quadrant.

Or, as suggested in the comments, you can use the "atan2" function that takes two arguments (thereby specifying the quadrant for you) and you'll get the right answer straight off.

Related Question