Angle Between Two Vectors Calculator

Enter the components of two 3D vectors to find the angle between them.

How it is calculated

For vectors a = (ax, ay, az) and b = (bx, by, bz) the tool computes the dot product a·b = ax·bx + ay·by + az·bz and the lengths |a| = √(ax² + ay² + az²) and |b| likewise. The angle follows from cos θ = a·b ÷ (|a| × |b|), so θ = arccos(cos θ). It is shown in degrees (two decimals) and in radians (four decimals), along with the dot product itself.

All six components are required; for a 2D problem enter 0 for the z components. The result is always between 0° and 180°, since it is the smaller angle between the two directions. If either vector is all zeros the angle is undefined and the tool shows nothing. The ratio is clamped to the range −1 to 1 before taking the arccosine, so tiny rounding errors for parallel vectors do not cause an error. Components may be negative or decimal, and no units are needed.

Worked example

Take a = (1, 2, 3) and b = (4, 5, 6). The dot product is 1×4 + 2×5 + 3×6 = 4 + 10 + 18 = 32. The lengths are |a| = √14 ≈ 3.7417 and |b| = √77 ≈ 8.7750. Then cos θ = 32 ÷ (3.7417 × 8.7750) ≈ 0.9746, and arccos of that gives 12.93°, which is 0.2257 rad. The two vectors point in nearly the same direction, so the angle is small and the dot product 32.00 is large and positive.

Try this example →

Common mistakes

  • Leaving a component blank, such as the z value of a 2D vector. All six fields are required, so enter 0.
  • Entering the points of a line instead of the vector. If you have start and end points, subtract them first to get the components.
  • Expecting an angle above 180°. The result is the smaller angle between the vectors, never more than 180°.
  • Using the zero vector, which has no direction, so the angle cannot be found.
  • Reading a negative dot product as an error. It simply means the angle is greater than 90°.

About this calculator

The angle between two vectors comes straight from the dot product formula: cos θ = (a · b) / (|a| |b|), where a · b is the sum of the products of matching components and |a|, |b| are the vectors' magnitudes. Taking the arccosine of that ratio gives θ directly, in radians, which this calculator also converts to degrees.

This is one of the most-used relationships in 3D math: computer graphics and game engines use it for lighting calculations and collision detection, physicists use it to resolve forces and torques, and robotics engineers use it for joint angles and motion planning. Because the dot product is zero exactly when vectors are perpendicular, this formula also doubles as the standard test for orthogonality.

Was this helpful?

You can pick up to 3 reactions.

Comments (1)

  • Editorial team

    Besides the angle, the sign of the dot product gives a quick sanity check: positive means under 90 degrees, zero means exactly 90, negative means more. For example, (1, 1, 0) and (1, -1, 0) have dot 0.00 and 90.00 degrees, and (1, 0, 0) with (-2, 0, 0) gives 180.00 degrees and dot -2.00. For flat 2D problems, put 0 in the z boxes. Which field are you using this in, graphics, physics or something else?

Popular calculators

All Calculators