Angle between two vectors

by Paweł Redman, published on , updated on

Figure 1: Which one to choose?

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:

1. Oriented angle

Figure 2: Oriented angles between example vectors u and v.

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:

or, equivalently:

Furthermore:

It’s also worth noting that:

which is why the dot product doesn’t carry enough information to compute .

1.1. In two dimensions

where the “two-dimensional cross product” is defined as:

1.2. Derivation: in two dimensions

Using the geometric definitions of the two-dimensional cross product (above) 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).