index

## Angle Between Two Vectors

How do we find the angle between two vectors?

Recall the dot product of vectors $\vec{a}$ and $\vec{b}$ in the real number space, $\mathbf{R}^n$ is in the form of:

There are two dependencies which lie within the vector dot product:

1. The angle between the two vectors.
2. The length of the input vectors.

Suppose we just want to find the angle of the two vectors using just the dot product. We'll need to find a way to remove the dependency of length within the dot product.

The easiest way to do this is to unitize the vectors, or normalize them. Or, simply, just convert them into unit vectors.

We can find the unit vector $\vec{u}$ from $\vec{a}$ by

Where in this case $||\vec{a}|| = \sqrt{a_0^2 + ... + a_n^2}$.

We can then unitize two vectors $\vec{a}$, $\vec{b}$, to $\vec{u}$, and $\vec{v}$. Then find use the alternate form of the dot product:

Since we know that $\vec{u}$, and $\vec{v}$ are unit vectors, then both lengths of these vectors are $1$. Which then the expression can be simplified to:

Using this expression, the angle $\theta$ between $\vec{u}$, and $\vec{v}$ is now the $arccos$ of the dot product.

### Notes

• We take advantage of the fact that the range of $\vec{u} \cdot \vec{v}$ can only range from $-1.0$ to $1.0$.