To main page | 3dengine.org

Heading, Pitch And Roll Angles


Heading, pitch and roll angles are Tait-Bryan angles, used in aeroplanes. They have many (incorrect I assume) definitions across the Web.

Tait-Bryan angles

Imagine a human standing still while looking forward.

Heading or yaw is when you start rotating left and right (with your hands), so it's a rotation around VERTICAL axis.

Pitch is when you start rotating with your arms around the axis that goes from your left ear to your right ear. (Which did rotate along when you changed your "heading").

Roll is when you tilt your head left of right after applying heading and pitch. The correct roll is when center of the screen stays in center, no matter what roll angle is applied.

Calculation

One of the ways to calculate heading-pitch-roll is to use quaternions like so:
Quat(0,0,1, roll) * Quat(1,0,0, pitch) * Quat(0,1,0, heading)
The order IS IMPORTANT. Apply roll first, then pitch, then heading.

glRotate

Using glRotate to calculate that kind of rotation will be tricky, since after you apply roll, your x and y axes are tilted and you need to apply pitch and heading to global x and y instead of new local ones. It might be possible to apply heading first (to 0,1,0), then pitch to (1,0,0) and then roll to (0,0,1), it probably should get correct result. Although this was not tested.