[Math] How to find clockwise angle of a point from the negative x-axis

trigonometry

Title pretty much says it. How can I rotate a point around the origin and find the clockwise angle of the point from the negative x-axis? I tried using the atan(height/width), but that gives me the angle in the specific quadrant, not from the negative x-axis.

Edit I got some good advice in the comments. What this question is really asking is, "How can I calculate the clockwise angle between a vector and the negative x-axis?". I was looking for a programming answer, but both perspectives (programming and not) are answered below.

Best Answer

Most programming languages provide an $\operatorname{atan2}$ function that deals with quadrants correctly. If you have a point $(x,y) \ne (0,0)$, then $\operatorname{atan2}(y,x)$ gives the counter-clockwise angle from the positive $x$-axis to $(x,y)$, in the range $(-\pi,\pi]$. Since you want the clockwise angle from the negative $x$-axis, it is enough to observe that when $\operatorname{atan2}(y,x) = 0$ the angle you want is $\pi$, and when it is $\pi/2$ you want $\pi/2$, so in general what you want is $\pi-\operatorname{atan2}(y,x)$, which lies in the range $[0,2\pi)$.

Related Question