Angle Between Vectors Calculator

Find the angle between two 2D or 3D vectors from their components, with the dot product, magnitudes and cosine.

Physics and EnergyUpdated 2026-11-183 min read
Angle Between Vectors Calculator
Angle between the vectors
...
Angle in radians...
Dot product...
Magnitude of vector A...
Magnitude of vector B...
Cosine of the angle...

What it does

Two vectors can point in almost any directions, and the angle between them tells you how much they agree. In two dimensions you could draw them and measure with a protractor, but in three dimensions a drawing is hard to read. The dot product gives the same answer from the components alone, which is why it appears in geometry, mechanics and computer graphics.

The key identity is that the dot product of two vectors equals the product of their lengths times the cosine of the angle between them. Rearrange it and the angle follows directly. Mathematics LibreTexts states this as cos θ = (v · w) / (|v| |w|) and notes that two vectors are orthogonal exactly when their dot product is zero.

That sign rule is useful before doing any arithmetic. A positive dot product means the vectors point broadly the same way and the angle is under 90 degrees. A negative value means they oppose each other and the angle is over 90 degrees. Zero means a right angle, so checking the dot product is a quick way to spot perpendicular directions.

This page handles both planar and space vectors. Switch to 2D to hide the z components, or keep 3D to enter all three. Alongside the angle you get the dot product, the length of each vector and the cosine, so you can see how each part of the formula was built.

One limitation is worth stating up front. If either vector has zero length, the angle is undefined because there is no direction to measure. The calculator rejects that case rather than returning a misleading number, and it also guards against rounding pushing the cosine just outside the range from -1 to 1.

How to use

  1. Choose 3D or 2D. The default 3D shows all three components of each vector.
  2. Enter the x component of vector A, then y, then z if shown.
  3. Enter the x, y and z components of vector B in the same order.
  4. Read the angle in degrees in the large result, with radians underneath.
  5. Check the dot product and the two magnitudes to confirm the calculation.
  6. Use the cosine value if you need it for a projection or another formula.

Formula

cos θ = (A · B) / (|A| |B|), with A · B = ax bx + ay by + az bz and |A| = sqrt(ax² + ay² + az²). Then θ = arccos(cos θ).
A, B
The two vectors, entered as separate x, y and z components.
ax, ay, az
Components of vector A along the three coordinate axes.
bx, by, bz
Components of vector B along the three coordinate axes.
|A|, |B|
Lengths, or magnitudes, of the two vectors.
θ
Angle between the vectors, from 0 to 180 degrees.

The inverse cosine always returns an angle between 0 and 180 degrees, so you do not need to pick a quadrant by hand. In 2D mode the z components are treated as zero, which is the same as embedding the vectors in the xy plane. Because floating point arithmetic can give a cosine slightly above 1 or below -1 for parallel vectors, the result is clamped to that range before the inverse cosine is taken.

Worked example

Example: the angle between (3, 4, -2) and (1, -5, 2)

Defaults: 3D vectors, A = (3, 4, -2) and B = (1, -5, 2).

  1. Dot product: 3 x 1 + 4 x (-5) + (-2) x 2 = 3 - 20 - 4 = -21.
  2. Length of A: sqrt(3² + 4² + (-2)²) = sqrt(29) = 5.3852.
  3. Length of B: sqrt(1² + (-5)² + 2²) = sqrt(30) = 5.4772.
  4. Cosine: -21 / (5.3852 x 5.4772) = -21 / 29.4958 = -0.7120.
  5. Inverse cosine of -0.7120 gives 2.3631 rad, which is 135.40 degrees.
  6. The tool shows 135.40 °, 2.3631 rad, dot -21, |A| 5.3852, |B| 5.4772 and cosine -0.7120.

Reference table

Angles for common direction pairs in the xy plane
Vector AVector BDot productAngle
(1, 0)(0, 1)090.00 °
(1, 0)(1, 0)10.00 °
(1, 0)(-1, 0)-1180.00 °
(1, 0)(1, 1)145.00 °
(1, 1, 0)(1, 1, 1)235.26 °

Limits

  • A zero vector has no direction, so the angle is undefined and the calculator returns an error.
  • The angle returned is the smaller one, between 0 and 180 degrees, not a signed rotation from A to B.
  • Components must be ordinary numbers; the tool does not solve for a missing component or accept symbolic entries.
  • Very large components are rejected to avoid overflow when the magnitudes are squared.

Common mistakes

  • Forgetting to include the z components in 3D, which changes both the dot product and the magnitudes.
  • Mixing the sign of a negative component when squaring it for the magnitude.
  • Using the cross product formula and then reading the angle as acute when the dot product is negative.
  • Assuming the angle depends on the length of the vectors. Scaling either vector does not change it.
  • Entering degrees into a formula that expects radians, or the reverse.

Try it yourself

Quick checks. Answers sit tucked under each question.

What is the angle between (1, 0) and (1, 1) in 2D?

The dot product is 1, the lengths are 1 and sqrt(2), so the cosine is 1 / 1.4142 = 0.7071 and the angle is 45.00 °.

Are (2, 3, -1) and (4, 1, 2) close to perpendicular?

The dot product is 8 + 3 - 2 = 9, not zero. With lengths sqrt(14) and sqrt(21) the cosine is 9 / 17.1464 = 0.5249, giving 58.34 °, so they are not perpendicular.

If both vectors are doubled, what happens to the angle?

Nothing. The dot product grows by four and each magnitude grows by two, so their ratio, the cosine, is unchanged. Two copies of the default pair still give 135.40 °.

Questions

What does the angle between two vectors tell me?

It measures how closely their directions agree. Zero degrees means they point the same way, 90 degrees means they are perpendicular and 180 degrees means they point opposite ways.

Why is the answer never more than 180 degrees?

The inverse cosine returns the smaller angle between two directions. A full turn in the other direction is just the same pair viewed the other way around, so one value from 0 to 180 degrees describes the pair.

What does a negative dot product mean?

It means the angle is obtuse, greater than 90 degrees. The vectors have components pointing against each other overall, which makes their product sum negative.

Can I use this for 2D vectors?

Yes. Choose 2D mode and the z components are hidden. The calculation then uses only x and y, treating both vectors as lying in the xy plane.

What happens if one vector is zero?

The angle is undefined because a zero vector has no direction. The calculator shows an error asking for nonzero components rather than dividing by zero.

Does the angle change if I scale a vector?

No. Scaling a vector multiplies both the dot product and that vector's magnitude by the same factor, so the cosine and the angle stay the same.

Sources

How this page was checked. The formula above was matched against the cited sources, and the worked example was run through the tool on this page before publishing. If you spot an error, contact us so we can fix it and note the correction.