LerpworksAcademy
On this page

Math and physics › Angles and rotations

Rotations in 3D: Euler angles and quaternions

Know first: Matrices: new axes, not a table of numbers

A rotation in 3D can be written as three angles, a matrix, an axis with an angle, or the four numbers of a quaternion. Angles are easy for a person to read, but they sometimes lock up, and they blend along awkward paths. A quaternion cannot be read by eye, yet it chains and blends rotations without either problem. This page explains why, and builds the quaternion from scratch with no higher math.

Why this matters

Rotations are everywhere in a game: a turret aims at its target, a camera follows the hero, a skeleton blends two animations. Three angles cause odd behavior. The camera tumbles when it looks straight up, a turret spins the long way around, and a hand in an animation swings off along an arc. So engines store rotations as quaternions internally and show angles only in the properties window. To see what happens between the two, you need the lessons on matrices, sine and cosine and interpolation.

Further in the article

  1. Four ways to write a rotation
  2. Euler angles: yaw, pitch and roll
  3. Gimbal lock
  4. Blending angles is a bad idea
  5. Axis and angle
  6. Quaternions in plain words
  7. Chaining rotations: multiplication
  8. Smooth rotation: slerp
  9. Where games use this
  10. Where it breaks
  11. Connections: the same idea in other fields
  12. Key points
  13. Test yourself