gl/ripetizioni

Attitude dynamics: Euler angles and quaternions explained

Attitude dynamics for aerospace engineering exams: rotation matrices, gimbal lock, quaternions, Euler's equations and stability, with worked exercises.

by Gaetano Livornese

Read the original in Italian

Attitude Dynamics is the exam where most aerospace engineering students find out that “understanding the orientation of a rigid body” is far subtler than it looks on paper. The syllabus brings together three different ways of describing a rotation — Euler angles, matrices, quaternions — and almost always asks for them together, in the same exercise, because each has an advantage and a flaw that the others cover. On top of this come Euler’s equations for the rigid body, which explain why a satellite (or a tennis racket) can start to spin in a messy way even with no external force. I take you through the syllabus with the logic I use in lessons with my aerospace engineering students, show you where the marks are lost, and we solve three exercises together with the calculations carried through to the end.

What the exam really asks

Euler angles and rotation sequences. An orientation in space can be described with three successive angles about axes that change at every rotation (this is why we speak of sequences, typically 3-2-1 or “yaw-pitch-roll” in aerospace: first yaw about , then pitch about the new , then roll about the new ). The total rotation matrix is the ordered product of the three elementary matrices:

Order matters: rotations do not commute, so . The problem with this representation is gimbal lock: when the middle angle (the pitch in the 3-2-1 sequence) reaches , the first and third rotation axes line up, and the system loses a degree of freedom — you can no longer tell yaw and roll apart, only their sum or difference. It is not a bug in your calculation, it is a geometric limit that is intrinsic to the three-angle representation.

Quaternions. A quaternion (or in compact notation with the scalar part and the vector part) represents a rotation without suffering from gimbal lock, at the cost of being less intuitive. Three properties the exam always asks about:

  • Unit norm: a rotation quaternion has . If your result does not have norm 1 (apart from rounding errors), you have got something wrong.
  • Composition of two rotations through the Hamilton product, — not commutative, exactly like matrices.
  • Kinematics, that is, how changes in time if the body rotates with angular velocity :

where here is the pure quaternion . This is the equation that is integrated numerically on board a real satellite to keep the estimated attitude up to date.

Euler’s equations for the rigid body. In the principal frame of inertia (axes aligned with the eigenvectors of the inertia tensor, principal moments ), the rotational dynamics with no external torques is:

From here comes the most beautiful (and most asked) result of the course: the stability of rotation about the principal axes. An asymmetric rigid body () rotates stably about the axis of maximum inertia and the axis of minimum inertia, but is unstable about the intermediate axis. This is the so-called tennis racket effect (or intermediate axis theorem): throw a racket in the air spinning it about the handle (the intermediate axis) and you will see that after a turn or two it starts to spin in a messy way, which does not happen if you spin it about the other two axes.

The course almost always closes with a brief look at gravity-gradient stabilisation (an elongated satellite tends to line up with its axis of minimum inertia pointing towards the Earth, because of the gravity gradient) and momentum/reaction wheels as actuators for active attitude control.

Where the marks are lost

  1. Getting the order of the Euler sequence wrong. is not . Before writing the product, write the physical sequence in words (“first I rotate about , then about the new …”) and translate it into matrices in the same order.

  2. Not recognising gimbal lock when the exercise puts it in front of you. If and the system of equations becomes singular (or the variables combine only as or ), the professor is checking whether you can recognise the phenomenon, not just compute it numerically.

  3. Confusing the Hamilton product with just any scalar or vector product. The quaternion product has a precise formula (the scalar part minus the dot product of the vector parts, plus cross terms with the cross product): it is not commutative and you do not “guess” it, you apply the formula.

  4. Forgetting that Euler’s equations are written in the principal frame of inertia. If the inertia tensor given in the exercise is not diagonal, it must first be diagonalised (eigenvalues = principal moments, eigenvectors = principal axes) before applying the equations in the form seen above.

  5. Proving the stability of the intermediate axis “from memory” instead of by linearising. The professor wants to see the linearisation of Euler’s equations about the nominal rotation and the sign of the resulting coefficient, not the stock phrase “the intermediate axis is unstable by the tennis racket theorem” with no calculation.

The method I use

  1. Always fix the convention (Euler sequence, scalar-first or scalar-last quaternion, principal frame or not) before writing the first equation: half of the errors come from a convention changed halfway through an exercise.
  2. Go from the physical description to the maths, not the other way round: describe in words the sequence of rotations or the configuration of the body, then write the equations.
  3. Always check the norm of a rotation quaternion after every composition: it is a thirty-second check that catches most calculation errors.
  4. For stability, always linearise about the nominal rotation and look at the sign of the resulting coefficient: positive (exponential, unstable), negative (oscillatory, stable).

Three solved exercises

Exercise 1 — The 3-2-1 rotation matrix and gimbal lock

Sequence (yaw), (pitch), (roll). The total matrix is (rounded to four digits):

Applied to the unit vector it gives : the new direction of the body’s axis, seen from the inertial reference frame.

Now repeat with (same ): gimbal lock.

Note the first row: , independent of both and . And the remaining elements depend only on the combination (or depending on the sequence), not on the two angles separately: you have lost a degree of freedom. This is exactly why real attitude control systems use quaternions for propagation, keeping Euler angles only as a “human” representation for the output.

Exercise 2 — Quaternion composition and kinematics

Compose a rotation of about with one of about , applying first and then , that is . The two quaternions are

With the Hamilton product formula the result is

Norm check:

Correct. Converting to axis-angle (): , about the axis — the diagonal of the cube. Two rotations of about orthogonal axes combine into a single rotation of about the diagonal: a result that with matrices would take more steps to see as clearly.

Kinematics: a body with current quaternion (reference orientation) and angular velocity rad/s has

At that instant, is simply half of (with zero scalar part) because is the identity; a numerical integration step would use this to update and then renormalise it to norm 1, since numerical integration introduces small errors that move away from the unit sphere.

Exercise 3 — Euler’s equations and stability of the intermediate axis

A rigid body with principal moments , , kg·m² (: axis 1 minor, axis 2 intermediate, axis 3 major). Check the stability of a nominal rotation rad/s about the intermediate axis (axis 2), and about the minor axis (axis 1).

Rotation about axis 2 (intermediate). Set constant, with small perturbations. Linearising Euler’s equations for and and differentiating a second time gives

With the given numbers:

Positive coefficient exponential solution : the perturbation grows, with a characteristic time s. Unstable, as predicted by the tennis racket theorem.

Rotation about axis 1 (minor). Same procedure with constant, perturbations on :

Negative coefficient oscillatory solution, , with angular frequency rad/s (a “wobble” period of about 2.3 seconds) that stays bounded in time: stable. The same calculation, repeated for axis 3 (major), gives the same negative sign: both extreme axes are stable, only the intermediate one is not.

I have written up the two other exams that usually come in the same block separately: orbital mechanics for Kepler, Hohmann and , and space systems engineering for the power and link budgets. If the course gets to attitude control, the stability of feedback systems is in the automatic control exam, and for the Lagrangian form of the same dynamics there is rational mechanics. To practise against the clock on basic mechanics, try the Physics 1 mock exam.

How we work in lessons

With Attitude Dynamics I always start by understanding which representation the exercise is asking you for and why — Euler angles for physical intuition, quaternions when numerical robustness is needed or when the exercise talks explicitly about attitude near gimbal lock, Euler’s equations when the subject is free dynamics or stability. We work on past exam papers from your own course, because the way each professor presents conventions (order of the sequences, scalar-first or scalar-last quaternion) changes from one course to another, and that is where the costliest careless errors hide.

If you are also preparing Orbital Mechanics or Rational Mechanics in the same semester, look at the page on university tutoring with all the practice tests by course, or at the physics page for the rest of the basic syllabus. And if a quaternion or stability exercise does not add up, book a free introductory call: send me the text and we will see together where the physical model slips away from you.

Keep reading

Want to put what you read into practice?

Let's talk for 30 minutes, free: we look together at where you are stuck and I tell you honestly how I can help.

Or message me on WhatsApp.