0
$\begingroup$

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

  • 0
    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)2017-02-21
  • 0
    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)2017-02-21
  • 0
    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)$](http://www.wolframalpha.com/input/?i=atan2(-20,-8)) instead of $\arctan(\frac yx)$. The downside is, though, that I've yet to see a calculator with an $\operatorname{atan2}$ key.2017-02-21
  • 0
    Thanks, atan2 did the trick. And i'm using javascript.2017-02-21

1 Answers 1

1

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.