[Math] Vectors Angles from $[0,2\pi]$

computer sciencegeometryMATLABvector-spaces

Given two vectors $V_1 = (x_1, y_1)$ and $V_2 = (x_2, y_2)$. How to calculate the angles between them in the range of $[0, 2\pi]$?

I know the $\cos\theta$ similarity equation could present a $\theta$ in the range of $[0, \pi]$.

Best Answer

You're right that the cos way only gets you the unsigned angle between 0 and 2$\pi$. If you can get the signed angle from $-\pi$ to $\pi$, then you can just add $2\pi$ to the negative answers.

But all you need to get the sign is to think of the two vectors as vectors in 3-space with 0 z-coordinate, and take the cross product. It will lie in the z direction. If it is positive, the angle is positive, and if it is negative, the angle is negative. If it is 0, then the angle is either 0 or $\pi$, which you can tell from the cos method.

Related Question