Table of Contents
Angle between two vectors
In there are two angles between any two vectors. The smallest one I'll call . The other one, its 360° complement, I'll call .
The smallest angle between two vectors and is given by:
which follows easily from the geometric definition of the dot product:
The other angle is simply the 360° complement:
Some applications call for the oriented angle . It's the angle going from one vector to the other in a specific direction. The convention that I use is that the direction be counter-clockwise.
Because the angle is oriented, changing the order of vectors (or the used convention) changes the angle's sign:
It's also worth noting that:
which is why the dot product doesn't carry enough information to compute .
In two dimensions
In any coordinate system:
Derivation: in two dimensions
Using the geometric definitions of the two-dimensional cross product and the dot product:
Solving for the sine and cosine:
Solving for (see Systems of equations involving the cosine and the sine of an unknown):
The simplification can be done because and eliminating it will not change the result (see properties of atan2).