How to calculate angle given x,y coordinate?

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

• Plot the point and draw a line from the origin to it. Drop a vertical to the nearest horizontal axis. You have a triangle with height 20 and base 8. Find the angle your line makes with the horizontal P = atan(20/8). Look at your picture and decide how much you need to add/subtract to this angle to get the one you want (+180 in your case)
– Paul
Feb 21, 2017 at 17:59
• isn't there a formula to always get the angle starting from the right side? (instead of adding if statements to add sub angles to it after) Feb 21, 2017 at 18:02
• If you don't want to have to remember that you have to add $180^\circ$ if the point is in QII or QIII or add $270^\circ$ if it's in QIV, then just use $\operatorname{atan2}(y,x)$ instead of $\arctan(\frac yx)$. The downside is, though, that I've yet to see a calculator with an $\operatorname{atan2}$ key.
– user137731
Feb 21, 2017 at 18:03
• Thanks, atan2 did the trick. And i'm using javascript. Feb 21, 2017 at 18:07

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.