StatGardenREF. DESK
Calculators/Geometry/Angle Between Two Vectors
Geometry

Angle Between Two Vectors calculator

Angle between two 2D or 3D vectors from their components, using the dot product.

Published 21 August 2026

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

Formulacos θ = (a·b) / (|a|·|b|)

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.

TermMeaning
a·bThe 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

FieldWhat to enter
a: xThe x component of vector a.
a: yThe y component of vector a.
a: z (0 for 2D)The z component of vector a; leave at 0 for a 2D vector.
b: xThe x component of vector b.
b: yThe 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.

a = (1, 0, 0), b = (x, 1, 0)
b: xAngle between the vectorscos θ
-3161.57°-0.9487
-1135.00°-0.7071
-0.5116.57°-0.4472
090.00°0
0.563.43°0.4472
145.00°0.7071
318.43°0.9487
At b: x = 0, vector b points straight up, perpendicular to a, giving exactly 90° and cos θ = 0. As b: x grows more positive the two vectors swing closer together; as it grows more negative they swing further apart, past 90° and towards 180°.

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 = (3, 4, z), b = (3, 0, 0)
a: zAngle between the vectorscos θ
053.13°0.6000
359.04°0.5145
667.41°0.3841
973.06°0.2914
1276.66°0.2308
2081.63°0.1455
At z = 0 both vectors sit in the same plane, giving the smallest angle in this table. As z grows, a tilts further out of that plane and the angle climbs steadily towards 90°, the limit for a vector tilted arbitrarily far out of the plane containing b.

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.