← Tutorials

Tutorial Series · Part 19 of 27

Attitude: Euler Angles, Rotation Matrices and Quaternions

Explain attitude representations and why quaternions are useful.

Series Context

Navigation from First Principles

This article is part of an ordered course. Use the previous and next links to stay in sequence.

Navigation is not only about where something is. It is also about which way it is pointing. Inertial systems need attitude so they can rotate body-frame IMU measurements into a navigation frame. Groves’ navigation references cover coordinate frames, kinematics, attitude and strapdown inertial navigation.12

The problem

Roll, pitch and yaw are easy to understand, but they can become awkward for computation. Rotation matrices are explicit but must stay orthonormal. Quaternions are less intuitive but efficient and avoid the classic Euler-angle gimbal-lock problem.

Euler angles

One common aerospace convention uses roll ϕ\phi, pitch θ\theta and yaw ψ\psi. A rotation matrix can be built from elemental rotations. For example:

C=Rz(ψ)Ry(θ)Rx(ϕ)\mathbf{C}=\mathbf{R}_z(\psi)\mathbf{R}_y(\theta)\mathbf{R}_x(\phi)

The exact order matters. A different order is a different convention.

Rotation matrix

A rotation matrix maps a vector from one frame to another:

vn=Cbnvb\mathbf{v}_n=\mathbf{C}_{b}^{n}\mathbf{v}_b

It should satisfy:

CCT=I\mathbf{C}\mathbf{C}^T=\mathbf{I}

and:

det(C)=1\det(\mathbf{C})=1

Quaternion

A quaternion can represent attitude as:

q=[q0,q1,q2,q3]T\mathbf{q}=[q_0,q_1,q_2,q_3]^T

with unit norm:

q=1\lVert \mathbf{q}\rVert=1

A gyro-driven quaternion update is:

q˙=12Ω(ω)q\dot{\mathbf{q}}=\frac{1}{2}\Omega(\boldsymbol{\omega})\mathbf{q}

Interactive demo: attitude representation explorer

The explorer below keeps Euler sliders as the user-facing input, then derives the matrix and quaternion displays from that same orientation.

Interactive Demo

Attitude Representation Explorer

Drive the pose with Euler angles, then compare the same attitude as a direction cosine matrix and quaternion. Rotation order matters.

Body axes follow the selected attitude

Controls

Try a large pitch angle, then switch rotation order or press the gimbal-lock preset to see how the representations differ.

Current representations

Euler0, 0, 0
Quaternion1, 0, 0, 0
Matrix row 11, 0, 0
Warningnone

What to watch

  • The same numeric angles produce different orientations when you change rotation order.
  • Near pitch 9090^\circ, the warning highlights where Euler-angle intuition becomes fragile.
  • The matrix and quaternion remain well-defined even when Euler angles become awkward.
  • Labelled axes make the frame convention explicit instead of implicit.

Try this

Set pitch near 9090^\circ and then vary roll and yaw. The demo should show how Euler-angle intuition becomes fragile near gimbal lock. Then rotate with quaternions and observe that the underlying orientation remains smooth.

Where this breaks

This post should avoid pretending one convention is universal. Aerospace, robotics, computer graphics and phone APIs may use different axes, handedness and rotation order. The safest habit is to state the convention every time.

Footnotes

  1. Paul D. Groves, Principles of GNSS, Inertial, and Multisensor Integrated Navigation Systems, Second Edition, Artech House, 2013. https://uk.artechhouse.com/Principles-of-GNSS-Inertial-and-Multisensor-Integrated-Navigation-Systems-Second-Edition-P1557.aspx - Core textbook reference for navigation systems, GNSS, INS, multisensor integration, coordinate frames, dead reckoning, feature matching and environmental aiding. Accessed 2026-06-11.

  2. Paul D. Groves, “Navigation Using Inertial Sensors”, IEEE Aerospace and Electronic Systems Magazine, 2015. https://ieee-aess.org/media/navigation-using-inertial-sensors - Tutorial covering inertial sensor technology, strapdown navigation, alignment, zero updates, motion constraints, pedestrian dead reckoning and fault detection. Accessed 2026-06-11.