Euler Angles: Yaw, Pitch and Roll
In the 3D mode, the drone turns to face a new boat, dips its nose to dive and banks as it curves round the lighthouse. The most human way to describe that pose is with three angles, and that is exactly what every engine's inspector panel shows you. Three angles are wonderfully readable, and they come with two famous traps.
The rule
Three turns in a fixed order; change the order, change the result.
Euler angles describe an orientation as three turns about the axes:
- Yaw: turn left or right, about the vertical axis.
- Pitch: nose up or down, about the sideways axis.
- Roll: tip one side down, about the forward axis.
"Yaw 90°, pitch −20°, roll 0°" is instantly clear to a person, takes just three numbers, and is what designers type. But the turns must be applied in an agreed order, because in 3D the order of rotations matters. Try it with a phone. Turn it a quarter-turn while it lies flat on the table, then tip it a quarter-turn toward you. Reset, and do the same two turns the other way round. It ends up in a different pose.
The second trap is gimbal lock. With yaw–pitch–roll, pitch the nose straight up to 90° and the roll axis now points along the vertical axis that yaw turns about. Changing yaw and changing roll do the same thing, and one way of turning is simply gone until the pitch comes back down. It isn't a bug in any engine; it's built into describing orientations with three separate angles.
A smaller trap is wrap-around: 350° and 10° are only 20° apart, but a naive blend from one to the other swings 340° the long way round.
The shortcut
Use Euler angles at the edges: inspector panels, save files and player input such as the chase camera's yaw and pitch. Inside the game, convert them to a matrix or quaternion before combining turns. Keep the camera's pitch between −89° and 89°, and before blending two angles, wrap the difference into the range −180° to 180°.
Naive difference
10 − 350 = −340. Blending by this sends the camera spinning 340° the long way round.
Drills
Answer fast — trust the rule.
Which angle turns the drone's nose left or right about the vertical axis?
With yaw–pitch–roll angles, what goes wrong at a pitch of 90°?
Why does the chase camera keep its pitch between −89° and 89°?
One drone gets "yaw 90°, then pitch 90°" and an identical drone gets "pitch 90°, then yaw 90°". How do they end up?
Remember
- Euler angles are yaw, pitch and roll applied in a fixed order; change the order and the pose changes.
- Gimbal lock at pitch ±90°: two of the three turns collapse into one.
- Use angles at the edges, convert inside, clamp the pitch, and wrap differences into −180° to 180°.
