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
- 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.
- 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
| Variable | Typical range | Lowest result | Highest result | Swing (°) | Local step | Change in result |
|---|---|---|---|---|---|---|
| ax x component of a | −10 to 10 | 25.41 | 137.6 | 112.2 | +0.4 | −4.98 ° |
| bz z component of b | −10 to 10 | 37.75 | 133.8 | 96.02 | +0.4 | −3.21 ° |
| by y component of b | −10 to 10 | 36.7 | 104.1 | 67.42 | +0.4 | −3.6 ° |
| az z component of a | −10 to 10 | 61.45 | 112.5 | 51.09 | +0.4 | −0.345 ° |
| ay y component of a | −10 to 10 | 43.89 | 90 | 46.11 | +0.4 | +3.12 ° |
| bx x component of b | −10 to 10 | 56.8 | 99 | 42.2 | +0.4 | +0.756 ° |
Sweep of x component of a
| x component of a | Angle between the vectors (°) |
|---|---|
| −10 | 137.6 |
| −7.5 | 133 |
| −5 | 124.5 |
| −2.5 | 107.4 |
| 0 | 75.99 |
| 2.5 | 45.87 |
| 5 | 31.83 |
| 7.5 | 26.93 |
| 10 | 25.41 |
Sweep one variable
Variables and how each one contributes
Angle between the vectors
What the equation gives you. Everything else feeds it.
x component of a
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 °.
y component of a
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 °.
z component of a
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 °.
x component of b
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 °.
y component of b
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 °.
z component of b
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
- Dot product: 1×4 + 2×−1 + 3×2 = 8.
- Lengths: |a| = 3.742 and |b| = 4.583, so cos θ = 8 / (3.742 × 4.583) = 0.46657.
- θ = 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