[Math] How to find the angle between vectors which is not necessarily the smallest angle

analytic geometrylinear algebra

I understand that in order to calculate the angle between two vectors one does the arccos of the results of the dot product divided by the product of the magnitude of the two vectors. However, this procedure always returns the smallest of the two angles. What I am interested in is the angle from vector v to vector u. This angle may excede $\pi$. I am using this in a computer program with data that I cannot inspect myself to know whever I should add $\pi$ to the angle or not. Any help would be greatly appreciated.

Best Answer

The question only makes sense if your vectors are from a two-dimensional vector space. In that case we also have the relation $$\sin\alpha =\frac{v_xu_y-v_yu_x}{|\mathbf u||\mathbf v|}. $$ From the combined signs of $\sin$ and $\cos$ you can determine the quadrant your angle is in (so in fact you only need the sign of $v_xu_y-v_yu_x$ as additional criterion). Thus we an say that the angle from $(1,0)$ to $(0,1)$ is $\frac\pi2$, but the angle from $(0,1)$ to $(1,0)$ or that from $(1,0)$ to $(0,-1)$ is $\frac{3\pi}2$ (or $-\frac\pi2$, if one prefers negative angles to angles $>\pi$).

To do the same in three or more dimensions, one would have to introduce the distinction between clockwise and anti-clockwise rotation in the plane spanned by two given vectors $\bf u$ amd $\bf v$. There is no poper way to introduce such an orientation (as we'd expect this way to be invariant under rotations). Therefore the range $[0,\pi]$ of angles as found per $\arccos$ is all we can hope for anyway.

Related Question