3D Rotations: Euler Angles & Gimbal Lock

Geometry & Trigonometry

Chapter 6 · 3D Rotations: Euler Angles & Gimbal Lock

Chapter 5 built 2D rotation to real depth — composition, arbitrary pivots, and a verified drift problem. The natural next step, extending rotation matrices to three dimensions and describing an orientation as three sequential rotations, seems straightforward. It has a real, mathematically inevitable failure mode: gimbal lock, verified concretely in this chapter, not just described.

3D Rotation Matrices: One Per Axis

Where 2D rotation had one matrix, 3D rotation needs three — one rotation around each axis:

Rx(θ) = [[1, 0, 0], [0, cos θ, -sin θ], [0, sin θ, cos θ]] Ry(θ) = [[ cos θ, 0, sin θ], [ 0, 1, 0], [-sin θ, 0, cos θ]] Rz(θ) = [[cos θ, -sin θ, 0], [sin θ, cos θ, 0], [ 0, 0, 1]]

A New Problem 2D Never Had: Rotations Around Different Axes Don't Commute

Chapter 5 showed that combining a rotation with a translation doesn't commute. In 3D, even combining two rotations around different axes — with no translation at all — doesn't commute either.

Verified directly — the same two 90° rotations, applied in opposite orders
Applying Rx(90°) then Ry(90°) to the point (0,0,1) gives (0, −1, 0). Applying the exact same two rotations in the opposite order — Ry(90°) then Rx(90°) — gives (1, 0, 0). Two completely different points on the unit sphere, from the identical pair of 90° rotations, differing only in which was applied first.

Euler Angles: Describing an Orientation as Three Sequential Rotations

An Euler angle representation describes any 3D orientation as three rotations applied in a chosen order around a chosen set of axes — commonly yaw (around z), pitch (around y), and roll (around x), combined as R = Rz(yaw)·Ry(pitch)·Rx(roll). It's intuitive — three familiar, independent-feeling knobs — and it's exactly how aircraft and camera orientation are usually described in plain language.

Gimbal Lock: A Real, Verified Loss of a Degree of Freedom

"Independent-feeling" is doing a lot of work in that sentence above. At one specific pitch value, 90°, yaw and roll stop being independent at all.

Verified directly — four genuinely different yaw/roll pairs, one identical rotation matrix
Computing the full orientation matrix R = Rz(yaw)·Ry(90°)·Rx(roll) for four different (yaw, roll) pairs that all share the same difference, yaw − roll = 20°(30°,10°), (40°,20°), (25°,5°), and (100°,80°) — produces exactly the same rotation matrix in all four cases, matching to floating-point precision: [[0, −0.342, 0.940], [0, 0.940, 0.342], [−1, 0, 0]].
Why this proves a genuine, permanent loss — not just "hard to control"
This isn't a coincidence or a rounding artifact — it can be derived algebraically: at pitch=90°, Rz(yaw)·Ry(90°)·Rx(roll) simplifies to a matrix that depends only on yaw − roll, never on yaw and roll individually. Two full turning knobs that felt independent everywhere else have collapsed into one effective parameter. An animation or flight-control system trying to adjust yaw and roll independently at this exact orientation would find that changing either one alone produces the identical visible rotation as changing the other — one entire degree of freedom of control has genuinely vanished, not merely become awkward.

"Gimbal lock" gets its name from a physical mechanical gimbal — a set of nested rotating rings, historically used in navigation instruments and spacecraft attitude systems, that suffers the exact same failure for the exact same geometric reason when two of its rings' axes become aligned.

Where This Connects

This chapter's findingWhat it sets up
3D rotation order-dependence, verified with two 90° rotationsA direct extension of Chapter 5's own 2D order-dependence finding into a genuinely new dimension of complexity
Gimbal lock verified as an exact, derivable loss of a degree of freedomThe central, motivating problem Chapter 7's quaternions are specifically built to avoid — not by making gimbal lock "less bad," but by using a representation that structurally can't exhibit it
The four-parameter matrix (3 Euler angles chosen from many possible axis orders)Chapter 8's coordinate-system transformations, which build on the same rotation-matrix machinery for full 3D scene transforms

Hands-On Exercises

Exercise 1

Using this chapter's own Rx and Ry matrices, apply Rx(90°) to the point (0,1,0), then apply Ry(90°) to the result. Separately, apply Ry(90°) to (0,1,0) first, then apply Rx(90°) to that result. Confirm the two final points are different.

📄 View solution
Exercise 2

Using this chapter's own verified gimbal-lock finding (that the resulting matrix at pitch=90° depends only on yaw − roll), predict without recomputing whether (yaw=60°, roll=40°) and (yaw=15°, roll=−5°) would produce the same rotation matrix at pitch=90°, and explain your reasoning.

📄 View solution
Exercise 3

A flight simulator's camera uses yaw/pitch/roll Euler angles and lets the player independently control yaw and roll with two separate joystick axes. Using this chapter's own gimbal-lock finding, describe specifically what the player would experience if the camera's pitch reached exactly 90° (looking straight up) while they tried to use both control axes.

📄 View solution

Chapter 6 Quick Reference

  • 3D rotation matrices: Rx, Ry, Rz, one per axis, each a direct extension of Chapter 5's 2D matrix
  • Verified: rotating (0,0,1) by Rx(90°) then Ry(90°) gives (0,−1,0); the opposite order gives (1,0,0) — 3D rotations don't commute even without translation
  • Euler angles: yaw/pitch/roll as three sequential axis rotations, R=Rz(yaw)·Ry(pitch)·Rx(roll)
  • Gimbal lock, verified: at pitch=90°, four genuinely different (yaw,roll) pairs sharing the same yaw−roll value produce exactly the same rotation matrix — a real, derivable, permanent loss of one degree of freedom, not just a control inconvenience
  • Next chapter: Quaternions — the standard practical fix, using a representation that structurally can't exhibit gimbal lock