Quaternions
Quaternions are a mathematical representation of 3D rotations using four parameters instead of three. This extra parameter eliminates singularities (gimbal lock) and enables smooth, continuous rotation calculations for any orientation.
Aspect | Euler Angles (Roll, Pitch, Yaw) | Quaternions |
Parameters | 3 numbers | 4 numbers |
Gimbal lock | Yes, at ±90° pitch | No singularities |
Interpolation | Jerky, non-linear | Smooth, linear |
Intuition | Very intuitive | Less intuitive |
Computation | Simple | Slightly more complex |
Visualization | Easy to picture | Hard to visualize |
Adding a fourth parameter solves gimbal lock:
Euler angles (3 params): Can become dependent when axes align
Quaternions (4 params): Always has 1 degree of freedom to avoid alignment (constrained to unit sphere). The extra parameter acts as a "safety buffer" that prevents axes from becoming parallel.