What this calculator does
The angle between two vectors tells you how far apart in direction they are, from 0° (pointing the same way) to 180° (pointing exactly opposite). It comes straight from the dot product: dividing a·b by the product of the two vector lengths gives cos θ, and taking the inverse cosine gives the angle itself. The calculation is identical for 2D and 3D vectors; for a 2D vector, just leave the z component at zero.
How to find the angle between two vectors is a common step in geometry, physics and computer graphics, wherever direction rather than distance is what matters, such as checking how closely two forces align or how two surface normals compare.
The formula
Take the dot product a·b (the sum of the products of matching components), and divide it by the product of the two vector magnitudes, |a| and |b|. That ratio is cos θ, so the angle itself is the inverse cosine (arccos) of that value.
| Term | Meaning |
|---|---|
| a·b | The dot product: a1×b1 + a2×b2 + a3×b3, summed across all components. |
| |a|, |b| | The magnitude (length) of each vector: the square root of the sum of its squared components. |
| θ | The angle between the two vectors, from 0° to 180°. |
The inputs explained
| Field | What to enter |
|---|---|
| a: x | The x component of vector a. |
| a: y | The y component of vector a. |
| a: z (0 for 2D) | The z component of vector a; leave at 0 for a 2D vector. |
| b: x | The x component of vector b. |
| b: y | The y component of vector b. |
| b: z (0 for 2D) | The z component of vector b; leave at 0 for a 2D vector. |
When to use it
Checking how two forces align
A small angle between two force vectors means they mostly reinforce each other; an angle near 180° means they mostly cancel. This calculator gives that angle directly from the force components.
Comparing directions in 3D graphics or physics
Surface normals, velocity vectors and light directions are all compared this way, since the angle between two 3D vectors is exactly what the dot product formula was built to answer.
Testing whether two vectors are perpendicular
Two vectors are perpendicular exactly when their dot product is zero, which shows up here as a 90° angle without needing to work out the full angle by hand.
Worked examples
Every figure in the tables below is produced by this page’s own calculator at build time, so the numbers and the tool always agree. Select any row to load that scenario.
How the angle changes as vector b rotates, in 2D
Vector a fixed along the x-axis, with the x component of vector b changing while its y component stays at 1.
| b: x | Angle between the vectors | cos θ |
|---|---|---|
| -3 | 161.57° | -0.9487 |
| -1 | 135.00° | -0.7071 |
| -0.5 | 116.57° | -0.4472 |
| 0 | 90.00° | 0 |
| 0.5 | 63.43° | 0.4472 |
| 1 | 45.00° | 0.7071 |
| 3 | 18.43° | 0.9487 |
How the angle changes as a 3D vector tilts out of a plane
Vector b fixed along the x-axis, with the z component of vector a increasing, tilting a further out of the plane that contains b.
| a: z | Angle between the vectors | cos θ |
|---|---|---|
| 0 | 53.13° | 0.6000 |
| 3 | 59.04° | 0.5145 |
| 6 | 67.41° | 0.3841 |
| 9 | 73.06° | 0.2914 |
| 12 | 76.66° | 0.2308 |
| 20 | 81.63° | 0.1455 |
Questions
Does this work for 2D vectors as well as 3D?
Yes. Set the z component of both vectors to 0 and the formula reduces to the standard 2D dot product, a1×b1 + a2×b2, giving exactly the 2D angle between them.
What does a negative dot product mean?
A negative dot product means the angle between the vectors is greater than 90°, so cos θ is negative. The vectors are pointing more away from each other than towards each other.
Why is the angle always between 0° and 180°?
The dot product formula only determines cos θ, and the inverse cosine of any value from −1 to 1 returns an angle in that 0° to 180° range by definition. It has no sense of which side a vector has rotated to, only how far apart in direction the two vectors sit.
How do I know if two vectors are perpendicular?
Check whether the dot product is zero. If a·b = 0, cos θ = 0 and the angle is exactly 90°, regardless of how long either vector is.
To project one vector onto another rather than just find the angle between them, see the vector projection calculator. For the plain length of a single vector, use the vector magnitude calculator.