Angle Between Two Vectors (2D) Formula

Angle Between Two Vectors (2D) Formula

Formula

Summary

This formula calculates the signed angle between two vectors in two-dimensions. To calculate the unsigned angle between two vectors of arbitrary degree, see this formula.

Expression Description
The angle between the two vectors.
The extended arc tangent function.
The first vector.
The second vector.

How to use

This formula calculates the signed angle between two vectors in two-dimensions. For example, given the vectors and the angle is calculated as:

Geometrically, this can be interpreted as the angle that rotates to in the counter-clockwise (positive) direction.

Example of positive angle returned between v = [-2 -3] and w = [5 -1]

If we change to be somewhere in the shaded region, as shown below, then the formula returns the angle that rotates to in the clockwise (negative) direction.

Example of positive angle returned between v = [-2 -3] and w = [-5 1]

Explanation

This formula calculates the signed angle between two vectors in two-dimensions using the extended arc tangent function. Geometrically, the signed angle represents the smallest possible rotation from to . In the example below, the calculated angle is negative because the shortest rotation occurs in the clockwise (negative) direction.

Example showing the signed angle calculated using this formula.

We can visualize when the angle will be positive or negative if we fix in place and divide the space into two regions on either side of . When lies in the region located in the counter-clockwise direction of , the angle is positive. When lies in the region clockwise to , the angle is negative.

Region highlighted grey where angles are negative

Arc Cosine Variation

There is another formula that calculates the unsigned angle between two vectors using the arc cosine function. This formula returns the smallest positive angle between two vectors.

If you compare the output of the formula on this page with the arc cosine formula, the difference can be seen in the shaded region, where the arc cosine formula returns the smallest positive angle between the two vectors.

Unsigned angles using arc cosine formula.

In other word, the arc cosine formula returns unsigned angles in the range to and the formula on this page returns signed angles in the range to .

Related Formulas

Angle Between Two Vectors (Unsigned)

To calculate the unsigned angle between two vectors of arbitrary degree you can use the arc cosine function. This formula calculates angles between negative 90 degrees and positive 90 degrees.