Angle Between Two Vectors Formula
The angle between two vectors is given by the arc cosine of the result from dividing their dot product by the product of their magnitudes.
Formula Terms
| Expression | Description |
|---|---|
| The angle between the two vectors, in radians. | |
| The arc cosine function. | |
| The first vector. | |
| The second vector. | |
| The dot product operator. | |
| The magnitude of the first vector. | |
| The magnitude of the second vector. |
This formula calculates the angle between two vectors, in radians, using the arc cosine function. For example, given the vectors and the angle is calculated as:
We can visualize the angle between these two vectors like this.
The angle returned from this formula is always greater than or equal to zero. In other words, the angle is unsigned and cannot be read as the action that rotates to . This is why the order of the vectors in the formula doesn’t matter: if you swap with , the formula produces the same angle.
We can visualize the angles this formula calculates by keeping in place and moving to different positions as shown below. To illustrate why these angles can’t be read as an action, I’ve drawn an arrowhead on each arc following the convention that a positive rotation turns counter-clockwise.
When you want the angle to describe an action, a rotation that takes one vector to the other, you need a formula that can return a negative result. To calculate the signed angle between vectors in two dimensions, see this formula.
The advantage of the formula on this page is that it works for higher dimensions like the angle between the two 3D vectors shown below.
To calculate the signed angle between two vectors in 2D you can use the extended arc tangent function. This formula returns the angle in radians, from −π to π, that rotates the first vector to the second vector.
The dot product of two vectors is calculated by summing together the product of corresponding elements.
The magnitude of a vector is given by the square root of the sum of its components squared.