Your Equation

Library / Foundations: Maths / FMA-61

Foundations: Maths

Angle between two vectors in three dimensions

Angle between two vectors, found from their dot product and lengths.

Ref
FMA-61
Rev
v1
Field
Foundations: Maths
Result
θ [°]

The dot product a·b = axbx + ayby + azbz equals |a||b| cos θ, so the angle between the vectors is arccos[a·b/(|a||b|)], between 0° and 180°. Both vectors must be nonzero. Because rounding can push the cosine just outside the range −1 to 1, clamp it before taking the inverse cosine (in a spreadsheet, before ACOS).

Angle between two vectors, found from their dot product and lengths. It lies between 0° and 180°; both vectors must be nonzero.

Calculator

Solve for
°
−1010
−1010
−1010
−1010
−1010
−1010
  • Dot product a·b8
  • Length |a|3.742
  • Length |b|4.583
  • Cosine of the angle0.4666

What drives the result

Each variable is moved across its typical range while the others stay at the values above. The longest bar is the key driver.

Angle between the vectors (°) current value 62.19 °
axx component of aKey driver
25.4138
bzz component of b
37.8134
byy component of b
36.7104
azz component of a
61.4113
ayy component of a
43.990
bxx component of b
56.899
  • The vectors (1, 2, 3) and (4, −1, 2) meet at 62.19°, since cos θ = 0.4666. A positive dot product means an angle below 90°, zero means perpendicular, negative means above 90°.
  • Scaling either vector does not change the angle; only the directions matter, which is why the lengths divide out.
Chart data as tables

Ranked variables

VariableTypical rangeLowest resultHighest resultSwing (°)Local stepChange in result
ax x component of a−10 to 10 25.41137.6112.2+0.4 −4.98 °
bz z component of b−10 to 10 37.75133.896.02+0.4 −3.21 °
by y component of b−10 to 10 36.7104.167.42+0.4 −3.6 °
az z component of a−10 to 10 61.45112.551.09+0.4 −0.345 °
ay y component of a−10 to 10 43.899046.11+0.4 +3.12 °
bx x component of b−10 to 10 56.89942.2+0.4 +0.756 °

Sweep of x component of a

x component of aAngle between the vectors (°)
−10137.6
−7.5133
−5124.5
−2.5107.4
075.99
2.545.87
531.83
7.526.93
1025.41

Sweep one variable

Angle between the vectors (°)Hover, touch, or use the arrow keys on the chart
20406080100120140 −10−50510 x component of a now 62.19

Variables and how each one contributes

θ

Angle between the vectors

Result · °

What the equation gives you. Everything else feeds it.

ax

x component of a

· typical −10 to 10

The x component of vector a, in the same units as the other components. Changes the angle by turning and stretching vector a: it adds bx to the dot product and also lengthens a, so the net effect depends on the directions. Raising it by 0.5 (to 1.5) moves the result by −9.91 %, from 62.19 to 56.03 °.

ay

y component of a

· typical −10 to 10

The y component of vector a, in the same units as the other components. Changes the angle by turning and stretching vector a: it adds by to the dot product and also lengthens a, so the net effect depends on the directions. Raising it by 0.5 (to 2.5) moves the result by +6.2 %, from 62.19 to 66.05 °.

az

z component of a

· typical −10 to 10

The z component of vector a, in the same units as the other components. Changes the angle by turning and stretching vector a: it adds bz to the dot product and also lengthens a, so the net effect depends on the directions. Raising it by 0.5 (to 3.5) moves the result by −0.657 %, from 62.19 to 61.78 °.

bx

x component of b

· typical −10 to 10

The x component of vector b, in the same units as the other components. Changes the angle by turning and stretching vector b: it adds ax to the dot product and also lengthens b, so the net effect depends on the directions. Raising it by 0.5 (to 4.5) moves the result by +1.5 %, from 62.19 to 63.12 °.

by

y component of b

· typical −10 to 10

The y component of vector b, in the same units as the other components. Changes the angle by turning and stretching vector b: it adds ay to the dot product and also lengthens b, so the net effect depends on the directions. Raising it by 0.5 (to −0.5) moves the result by −7.24 %, from 62.19 to 57.69 °.

bz

z component of b

· typical −10 to 10

The z component of vector b, in the same units as the other components. Changes the angle by turning and stretching vector b: it adds az to the dot product and also lengthens b, so the net effect depends on the directions. Raising it by 0.5 (to 2.5) moves the result by −6.37 %, from 62.19 to 58.23 °.

Worked example with the values above

  1. Dot product: 1×4 + 2×−1 + 3×2 = 8.
  2. Lengths: |a| = 3.742 and |b| = 4.583, so cos θ = 8 / (3.742 × 4.583) = 0.46657.
  3. θ = arccos(0.46657) = 62.19°.

Assumptions and limits

  • Both vectors are nonzero and expressed in the same coordinate system and units.
  • Rounding can push the cosine slightly outside −1 to 1; the calculation clamps it before taking the inverse cosine.

Common mistakes

  • Forgetting to divide by the product of the lengths.
  • Using the angle formula on a zero vector.
  • Not clamping the cosine to [−1, 1] before ACOS.

Statistics and uncertainty

Near 0° and 180° the cosine is flat, so the angle is very sensitive to errors in the components: a tiny change in the cosine changes the angle a lot. The angle is best determined when the vectors are not nearly parallel.

Where it is used

  • The angle between two forces, members or velocity vectors.
  • The angle between a force and a surface normal.

Maths you need

  • Dot product: sum of products of matching components
  • Vector length: square root of the sum of squared components

Related formulas

Practise this formula