Flow Lab

Syllabus / Module 12: Applications: Flight & Aerospace

Lesson 12.3

Rigid-Body Dynamics & Rotations

Rotation matrices, Euler angles, gimbal lock, quaternions, angular velocity, inertia tensors and Euler's rotation equations.

Written byClaude Opus

🌊
Why this matters for simulation: Every flight simulator integrates these equations each frame.

By the end of this lesson you can…

  • Read a rotation matrix as the body axes in world coordinates, check $R^{\mathsf T}R = I$ and $\det R = 1$, and show that 3-D rotations do not commute.
  • Derive the yaw-pitch-roll Euler-angle kinematics and explain gimbal lock at $\theta = \pm90^\circ$ as a determinant $\cos\theta$ going to zero.
  • Rotate and compose with unit quaternions, integrate $\dot q = \tfrac12 q\otimes(0, \boldsymbol\omega)$, and say what renormalisation fixes.
  • Find principal axes as the orthogonal eigenvectors of the symmetric inertia tensor, and derive Euler's equations and their two invariants.
  • Prove the intermediate-axis theorem by linearisation and compute the growth rate and flip period for a box and a light aircraft.
  • Measure invariant drift for forward Euler, RK4 and a splitting method, and compare Euler-angle with quaternion integration through a loop.
On this page
·
  1. Rotation matrices
  2. Euler angles and gimbal lock
  3. Quaternions
  4. The inertia tensor
  5. Worked example: the light aircraft
  6. Euler’s equations
  7. Which spins are stable
  8. Integrating it
  9. Gimbal lock in an integrator
  10. Computing it
  11. Concept checks
  12. Problems
  13. Key Takeaways

12.2 Thin Airfoil Theory & Panel Methods left the light aircraft able to make lift: 12 63312\,633 N from a NACA 2412 wing at about 3.2∘3.2^\circ. But flying is mostly rotating, and a simulator must know where the nose points at every step. In 2-D an orientation is one angle. In 3-D the order of turns matters, the obvious three angles break down when the nose points straight up, and a spinning body can flip over by itself. This lesson builds a flight simulator’s attitude tools and the equations that move them.

Tools: 1.2 Matrices as Transformations, 1.4 Determinants as Volume Scaling, 1.6 Change of Basis & Diagonalization, 7.7 Nonlinear Systems & Linearization, 4.3 Runge–Kutta Methods & Butcher Tableaux, 4.7 Energy & Symplectic Integrators.

▶ Video Rotation matrices as body axes, non-commuting turns, gimbal lock at pitch 90 degrees, quaternions, and a box flipping about its intermediate axiscaptions only
Transcript
  1. Last lesson left a light aircraft that makes lift: 12 633 newtons from a NACA 2412 wing. But flying is mostly rotating. The order of turns matters, the obvious three angles break down when the nose points straight up, and a spinning body can flip over by itself.
  2. A rotation matrix has the body axes as columns, in world coordinates: x north, y east, z down. Column one is the nose. Its transpose is its inverse, its determinant plus one. Now turn this aircraft. Roll ninety degrees, then yaw ninety: the nose swings east. Yaw first, then roll: the nose points down. Rotations do not commute.
  3. The aerospace angles are yaw, pitch and roll. Gyros measure body rates, and the angle rates come from a matrix whose determinant is cosine theta. Near vertical that vanishes: gimbal lock. With a body yaw rate of 0.1 radians per second, heading must change at 0.576 at pitch 80 degrees, 5.730 at 89, and 57.296 at 89.9. The aircraft barely moves; the coordinates race.
  4. So spend a fourth number. A turn by alpha about axis n is the quaternion cosine half alpha, n sine half alpha. Composition is multiplication: roll then yaw is a single 120 degree turn about the diagonal, one half, one, one, one. The kinematics are q dot equals one half q times zero omega: linear, with no division, on a sphere with no poles.
  5. Fly a loop at 0.5 radians per second with a small yaw, 0.001, integrating angles and quaternion by RK4. The Euler angles spike near the top, 200 radians per second, and end 7.3353 degrees off. The quaternion misses by 7.3 times 10 to the minus 8 degrees.
  6. A spinning body has angular momentum L equals I omega. The inertia tensor is symmetric, so its eigenvectors are perpendicular: the principal axes. Our light aircraft has eigenvalues 1521.8, 2462.0 and 3618.7 kilogram metres squared, and its roll axis tilts 2.94 degrees nose-down. The simulator's box is 5, 10 and 13 over 1200.
  7. Newton holds in the world, but I is constant only in the body. Differentiating a turning vector adds a term, giving Euler's equations. With no moment there are two invariants: the energy, and the length of L. An integrator should keep both: free error meters.
  8. Spin the box about its middle axis, one turn per second. That axis is a saddle: perturbations grow at lambda equals 3.0183 per second, e-folding every 0.3313 seconds. And the box flips. The spin rate first changes sign at 2.398 seconds, then every 4.0665. A perturbation ten times smaller delays the first flip by 0.763 seconds, natural log ten over lambda.
  9. Over twenty seconds, five flips, forward Euler's energy grows by thirty-nine percent. RK4 at 0.01 seconds drifts by minus 4.2 times 10 to the minus 9. The splitting method rotates exactly about each principal axis in turn: L exact to round-off, energy error 1.1 times 10 to the minus 7, oscillating, never growing.
  10. A thousand newton-metres turns the aircraft at 0.657 radians per second squared in roll, 0.406 in pitch, 0.276 in yaw: roll starts easiest. From memory: Explorer 1, 1958, spun about its minimum axis, lost energy, and tumbled end over end. And the Dzhanibekov effect: a wing nut flipping aboard Salyut 7, 1985.
  11. Rotation is now in hand. Next, 12.4: the six-degree-of-freedom model joins it to lift, in twelve states, advanced by one RK4 loop.

Rotation matrices

The world frame (aerospace convention) has xx north, yy east, zz down. The body frame is glued to the aircraft: xbx_b out of the nose, yby_b out of the right wing, zbz_b out of the belly. A vector with body components vb\mathbf v_b has world components

v=R vb,R=[ x^b  y^b  z^b ].\mathbf v = R\,\mathbf v_b, \qquad R = \big[\,\hat{\mathbf x}_b\ \ \hat{\mathbf y}_b\ \ \hat{\mathbf z}_b\,\big].

As in 1.2, the columns are where the basis vectors go: column 1 is the nose direction in world coordinates. Three facts follow.

  • Orthogonal. Entry (i,j)(i, j) of RTRR^{\mathsf T}R is the dot product of columns ii and jj, perpendicular unit vectors, so RTR=IR^{\mathsf T}R = I and R−1=RTR^{-1} = R^{\mathsf T}.
  • Determinant +1+1. Rotations keep volume and handedness; a mirror has orthogonal columns but determinant −1-1.
  • Not commutative. Roll 90∘90^\circ about north (RxR_x), then yaw 90∘90^\circ about down (RzR_z): the roll leaves the nose alone and the yaw swings it east, RzRxx^=(0,1,0)R_zR_x\hat{\mathbf x} = (0, 1, 0). Yaw first: the nose goes east, then the roll about north tips it down, RxRzx^=(0,0,1)R_xR_z\hat{\mathbf x} = (0, 0, 1). Plane rotations commute (1.2); these do not.

Euler angles and gimbal lock

The aerospace angles are yaw ψ\psi, pitch θ\theta, roll ϕ\phi, applied in that order (the 3-2-1 sequence): R=Rz(ψ)Ry(θ)Rx(ϕ)R = R_z(\psi)R_y(\theta)R_x(\phi). The trouble is their kinematics. Rate gyros measure body rates (p,q,r)(p, q, r); each angle turns about a different axis (ϕ˙\dot\phi about xbx_b, θ˙\dot\theta about the once-rotated yy, ψ˙\dot\psi about world zz). Writing those axes in body components and adding,

[pqr]=[10−sin⁡θ0cos⁡ϕsin⁡ϕcos⁡θ0−sin⁡ϕcos⁡ϕcos⁡θ][ϕ˙θ˙ψ˙],\begin{bmatrix} p \\ q \\ r\end{bmatrix} = \begin{bmatrix} 1 & 0 & -\sin\theta \\ 0 & \cos\phi & \sin\phi\cos\theta \\ 0 & -\sin\phi & \cos\phi\cos\theta \end{bmatrix} \begin{bmatrix} \dot\phi \\ \dot\theta \\ \dot\psi\end{bmatrix},

a matrix with determinant cos⁡θ\cos\theta. Inverting it:

ϕ˙=p+(qsin⁡ϕ+rcos⁡ϕ)tan⁡θ,θ˙=qcos⁡ϕ−rsin⁡ϕ,ψ˙=qsin⁡ϕ+rcos⁡ϕcos⁡θ.\dot\phi = p + (q\sin\phi + r\cos\phi)\tan\theta, \quad \dot\theta = q\cos\phi - r\sin\phi, \quad \dot\psi = \frac{q\sin\phi + r\cos\phi}{\cos\theta}.

At θ=±90∘\theta = \pm90^\circ the determinant vanishes: with the nose vertical, the yaw axis and the roll axis coincide and one direction of the column space is lost (1.3 Linear Systems, Kernel & Column Space). That is gimbal lock. The aircraft is fine; the coordinates demand huge rates for ordinary motion. A pure body yaw rate r=0.1r = 0.1 rad/s at zero roll gives ψ˙=r/cos⁡θ\dot\psi = r/\cos\theta, ϕ˙=rtan⁡θ\dot\phi = r\tan\theta (gimbal sim readout):

pitch θ\thetaψ˙\dot\psi (rad/s)ϕ˙\dot\phi (rad/s)
80∘80^\circ0.5760.567
89∘89^\circ5.7305.729
89.9∘89.9^\circ57.29657.296

The physical roll rate p=ϕ˙−ψ˙sin⁡θp = \dot\phi - \dot\psi\sin\theta stays exactly 00: the two angles race together while the aircraft barely moves. Every 3-parameter description of attitude has such a point somewhere (a topological theorem, quoted from memory), so we spend a fourth number.

Quaternions

A quaternion q=(w,u)q = (w, \mathbf u) is a scalar and a 3-vector with the product

(w1,u1)⊗(w2,u2)=(w1w2−u1⋅u2,  w1u2+w2u1+u1×u2),(w_1, \mathbf u_1)\otimes(w_2, \mathbf u_2) = \big(w_1w_2 - \mathbf u_1\cdot\mathbf u_2,\ \ w_1\mathbf u_2 + w_2\mathbf u_1 + \mathbf u_1\times\mathbf u_2\big),

non-commutative through the cross product, like rotations. A turn by α\alpha about the unit axis n^\hat{\mathbf n} is the unit quaternion q=(cos⁡α2,n^sin⁡α2)q = (\cos\tfrac\alpha2, \hat{\mathbf n}\sin\tfrac\alpha2), and it rotates vectors by (0,v′)=q⊗(0,v)⊗q∗(0, \mathbf v') = q\otimes(0, \mathbf v)\otimes q^*, with q∗=(w,−u)q^* = (w, -\mathbf u). Expanded, it is a matrix R(q)R(q) with R11=1−2(y2+z2)R_{11} = 1 - 2(y^2 + z^2), and so on.

  • Composition is multiplication: q2q_2 then q1q_1 is q1⊗q2q_1\otimes q_2, and R(q1⊗q2)=R(q1)R(q2)R(q_1\otimes q_2) = R(q_1)R(q_2).
  • Double cover: qq and −q-q are the same rotation, since the signs cancel in q⊗v⊗q∗q\otimes\mathbf v\otimes q^*. A 360∘360^\circ turn is (−1,0)(-1, \mathbf 0).
  • No singularity: unit quaternions fill the 3-sphere w2+x2+y2+z2=1w^2 + x^2 + y^2 + z^2 = 1, which has no poles, and R(q)R(q) is smooth and two-to-one everywhere. The price is the constraint ∣q∣=1|q| = 1.

Kinematics. In a short dtdt the body turns by ∣ω∣dt|\boldsymbol\omega|dt about its own ω\boldsymbol\omega: q(t+dt)=q⊗(1,12ω dt)q(t + dt) = q\otimes(1, \tfrac12\boldsymbol\omega\,dt), so

q˙=12 q⊗(0,ω).\dot q = \tfrac12\,q\otimes(0, \boldsymbol\omega).

Linear, with no division anywhere. The exact flow keeps ∣q∣=1|q| = 1 (the scalar part of q∗⊗q˙q^*\otimes\dot q is 00); a numerical method does not, so codes renormalise, q←q/∣q∣q \leftarrow q/|q|. Because q˙\dot q is linear in qq, a wrong length never feeds back into the direction: renormalising changes no attitude computed from q/∣q∣q/|q|. It matters for code that uses the RR formula unnormalised, which stretches the body.

The inertia tensor

Particles of a spinning body move at ω×r\boldsymbol\omega\times\mathbf r, so the angular momentum about the centre of gravity is

L=∑m r×(ω×r)=Iω,I=∑m(∣r∣2 1−rrT),\mathbf L = \sum m\,\mathbf r\times(\boldsymbol\omega\times\mathbf r) = I\boldsymbol\omega, \qquad I = \sum m\big(|\mathbf r|^2\,\mathbb 1 - \mathbf r\mathbf r^{\mathsf T}\big),

by a×(b×c)=b(a⋅c)−c(a⋅b)\mathbf a\times(\mathbf b\times\mathbf c) = \mathbf b(\mathbf a\cdot\mathbf c) - \mathbf c(\mathbf a\cdot\mathbf b). The diagonal holds the moments of inertia, Ixx=∑m(y2+z2)I_{xx} = \sum m(y^2 + z^2); off the diagonal sit products of inertia like −∑mxz-\sum mxz. In general L\mathbf L is not parallel to ω\boldsymbol\omega.

II is symmetric, so the spectral theorem (1.6) gives real eigenvalues and three perpendicular eigenvectors: the principal axes. Spin about one and L\mathbf L points along the spin; in that frame I=diag(I1,I2,I3)I = \mathrm{diag}(I_1, I_2, I_3). A uniform box with sides a,b,ca, b, c has I1=m(b2+c2)/12I_1 = m(b^2 + c^2)/12 and cyclic. The sim’s box, 0.3×0.2×0.10.3\times0.2\times0.1 m and 11 kg, has I=(5,10,13)/1200I = (5, 10, 13)/1200 kg m2^2.

Worked example: the light aircraft

Assume (rough, invented here) 11001100 kg in five uniform boxes: engine and propeller (150 kg), cabin with people and fuel (710), a high wing 1111 m by 1.51.5 m (120), tail cone (70) and tail surfaces (50); the lab cell lists positions and sizes. Shift to the centre of gravity and add each box’s own inertia to its parallel-axis term m(∣r∣21−rrT)m(|\mathbf r|^2\mathbb 1 - \mathbf r\mathbf r^{\mathsf T}). The lab cell gets, in kg m2^2,

I=[1527.30−107.602462.00−107.603613.1].I = \begin{bmatrix} 1527.3 & 0 & -107.6 \\ 0 & 2462.0 & 0 \\ -107.6 & 0 & 3613.1\end{bmatrix}.

Left-right symmetry kills IxyI_{xy} and IyzI_{yz}; the engine low in front and the wing and tail high behind leave Ixz≠0I_{xz} \ne 0. The eigenvalues are 1521.81521.8, 2462.02462.0, 3618.73618.7, and the roll eigenvector tilts 2.94∘2.94^\circ nose-down from xbx_b, along the line the masses lie on. Published Cessna 172 values are about 12851285, 18251825, 26672667 kg m2^2 (from memory): crude lumps, right order.

Why Ixx<Iyy<IzzI_{xx} \lt I_{yy} \lt I_{zz}. The wing’s mass lies far out along yy, counting in IxxI_{xx} and IzzI_{zz}; the fuselage’s length counts in IyyI_{yy} and IzzI_{zz}. Yaw pays for both (a flat body has Izz=Ixx+IyyI_{zz} = I_{xx} + I_{yy} exactly; here 3613.13613.1 against 3989.33989.3). A 10001000 N m moment gives 1000/1521.8=0.6571000/1521.8 = 0.657 rad/s2^2 in roll, 0.4060.406 in pitch, 0.2760.276 in yaw: roll is easiest to start.

Euler’s equations

Newton says dL/dt=Md\mathbf L/dt = \mathbf M in the world frame, but II is constant only in the body, so write L=R (Iω)\mathbf L = R\,(I\boldsymbol\omega). Each column of RR is a body axis turning at ω\boldsymbol\omega, so for any body-component vector b\mathbf b, ddt(Rb)=R(b˙+ω×b)\frac{d}{dt}(R\mathbf b) = R(\dot{\mathbf b} + \boldsymbol\omega\times\mathbf b): the change seen in the body plus the turning of the frame. With b=Iω\mathbf b = I\boldsymbol\omega, in body axes:

Iω˙+ω×(Iω)=M,I\dot{\boldsymbol\omega} + \boldsymbol\omega\times(I\boldsymbol\omega) = \mathbf M ,

Euler’s equations. In principal axes with ω=(p,q,r)\boldsymbol\omega = (p, q, r): I1p˙=(I2−I3)qr+M1I_1\dot p = (I_2 - I_3)qr + M_1, I2q˙=(I3−I1)rp+M2I_2\dot q = (I_3 - I_1)rp + M_2, I3r˙=(I1−I2)pq+M3I_3\dot r = (I_1 - I_2)pq + M_3.

Two invariants when M=0\mathbf M = 0. Dot with ω\boldsymbol\omega: ω⋅Iω˙=−ω⋅(ω×Iω)=0\boldsymbol\omega\cdot I\dot{\boldsymbol\omega} = -\boldsymbol\omega\cdot(\boldsymbol\omega\times I\boldsymbol\omega) = 0, which (II symmetric) says E=12ω⋅IωE = \tfrac12\boldsymbol\omega\cdot I\boldsymbol\omega is constant. Dot with IωI\boldsymbol\omega: ∣L∣|\mathbf L| is constant, and in the world frame the whole vector L\mathbf L is. An integrator should keep both: free error meters.

Which spins are stable

Spin at Ω\Omega about axis 2 and perturb: ω=(p,Ω+δ,r)\boldsymbol\omega = (p, \Omega + \delta, r), all small but Ω\Omega. Dropping products of small terms (7.7 Nonlinear Systems & Linearization), p˙=I2−I3I1Ωr\dot p = \frac{I_2 - I_3}{I_1}\Omega r, r˙=I1−I2I3Ωp\dot r = \frac{I_1 - I_2}{I_3}\Omega p, δ˙=0\dot\delta = 0. Differentiate the first and substitute: p¨=λ2p\ddot p = \lambda^2p with

λ2=(I2−I3)(I1−I2)I1I3 Ω2.\lambda^2 = \frac{(I_2 - I_3)(I_1 - I_2)}{I_1I_3}\,\Omega^2 .

The Jacobian’s eigenvalues are ±λ\pm\lambda. If I2I_2 is the largest or smallest moment, the brackets have opposite signs, λ2<0\lambda^2 \lt 0, the eigenvalues are imaginary and the axis only wobbles. If I2I_2 is intermediate, I1<I2<I3I_1 \lt I_2 \lt I_3, both brackets are negative and one eigenvalue is real and positive: a saddle. That is the intermediate-axis theorem.

Numbers (sim readout, Ω=2π\Omega = 2\pi rad/s, one turn per second):

  • Box: λ=Ω15/65=3.0183\lambda = \Omega\sqrt{15/65} = 3.0183 s−1^{-1}, so perturbations e-fold every 0.33130.3313 s. About xx it wobbles at 3.4853.485 rad/s, about zz at 4.3534.353 rad/s.
  • Light aircraft about pitch, its intermediate axis: λ=2.7921\lambda = 2.7921 s−1^{-1}, e-folding in 0.35810.3581 s.

The flip. In body axes L\mathbf L lies on the sphere ∣L∣=|\mathbf L| = const and on the ellipsoid ∑Li2/Ii=2E\sum L_i^2/I_i = 2E. Their intersections are small loops round axes 1 and 3, but through axis 2 they are crossing curves that run to the opposite pole. So the body flips, and flips back, periodically. Start the box at ω0=Ω(0.01,1,0.01)\boldsymbol\omega_0 = \Omega(0.01, 1, 0.01): ωy\omega_y first changes sign at 2.3982.398 s, then every 4.06654.0665 s. With a ten times smaller perturbation the first flip comes 0.7630.763 s later, which is ln⁡10/λ\ln 10/\lambda: the growth rate at work. This is the Dzhanibekov effect, after the cosmonaut who saw a wing nut flip every few seconds on Salyut 7 in 1985 (from memory), and the tennis-racket theorem on Earth.

◆ Interactive A tumbling body integrated with quaternions: spin a box or the light aircraft about any principal axis and watch the body rates, the fixed angular momentum and the invariants

Loading simulation…

The green world L\mathbf L stays fixed while the box turns over; the chart shows ωy/Ω\omega_y/\Omega swinging between +1+1 and −1-1 while ωx\omega_x and ωz\omega_z bulge at each flip. The light aircraft, spun about pitch, keeps turning over so that its right wing swings round to where the left one was, and its own pitch rate reverses (first at 2.2482.248 s).

Integrating it

The state is (q,ω)(q, \boldsymbol\omega), seven numbers. The sim’s 20 s check runs the box (Ω=2π\Omega = 2\pi, perturbation 0.010.01) through five flips:

method, hhE/E0−1E/E_0 - 1∣L−L0∣/∣L0∣\lvert\mathbf L - \mathbf L_0\rvert/\lvert\mathbf L_0\rvert∣q∣−1\lvert q\rvert - 1
forward Euler, 0.010.01 s3.9×10−13.9\times10^{-1}1.8×10−11.8\times10^{-1}2.32.3
forward Euler, 0.0050.005 s1.7×10−11.7\times10^{-1}8.2×10−28.2\times10^{-2}7.4×10−17.4\times10^{-1}
RK4, 0.020.02 s−1.3×10−7-1.3\times10^{-7}3.9×10−73.9\times10^{-7}−5.5×10−7-5.5\times10^{-7}
RK4, 0.010.01 s−4.2×10−9-4.2\times10^{-9}2.4×10−82.4\times10^{-8}−1.7×10−8-1.7\times10^{-8}
splitting, 0.010.01 s1.1×10−71.1\times10^{-7}1.4×10−141.4\times10^{-14}−3.3×10−16-3.3\times10^{-16}

Forward Euler is first order and its energy grows, 39% in 20 s (4.2 The Euler Family: Forward, Backward, Heun & Midpoint). RK4 is fourth order: halving hh cuts the energy error by 3232. Tick renormalise and ∣q∣−1|q| - 1 drops to round-off while the EE and L\mathbf L columns do not change at all, as the linearity argument predicts.

The splitting method is the rigid-body kick-and-drift of 4.7. Write E=∑Li2/(2Ii)E = \sum L_i^2/(2I_i); each term alone is an exact rotation about one principal axis at rate Li/IiL_i/I_i. Do half a step of 1, half of 2, a full step of 3, half of 2, half of 1, each exactly. Every piece is a rotation, so L\mathbf L is kept to round-off and ∣q∣|q| never drifts. The energy error is second order and, like velocity Verlet’s, oscillates without growing: it peaks at 4.9×10−54.9\times10^{-5} during flips, and press 2000 s check: the peak is the same. RK4’s error is smaller but grows steadily, 4.2×10−94.2\times10^{-9} at 20 s, 4.1×10−74.1\times10^{-7} at 2000 s.

Gimbal lock in an integrator

Now integrate the angles. Fly a loop at pitch rate q=0.5q = 0.5 rad/s with a small body yaw rate rr, and integrate (ϕ,θ,ψ)(\phi, \theta, \psi) by RK4 beside RK4 on the quaternion. The body rates are constant, so the exact attitude is one rotation about a fixed axis, q(t)=(cos⁡Wt2,ωWsin⁡Wt2)q(t) = (\cos\tfrac{Wt}2, \tfrac{\boldsymbol\omega}W\sin\tfrac{Wt}2) with W=∣ω∣W = |\boldsymbol\omega|, and the sim measures both errors against it.

The nose passes arctan⁡(r/q)\arctan(r/q) from vertical. Near the top heading and roll each swing by almost 180∘180^\circ, half of it within about r/q2r/q^2 seconds, at peak rates near q2/rq^2/r. For r=0.005r = 0.005: a 0.573∘0.573^\circ miss, 0.020.02 s, 5050 rad/s.

◆ Interactive Gimbal lock: one loop with a little yaw, integrated by RK4 as Euler angles (right) and as a quaternion (left), against the exact attitude (dashed outline)

Loading simulation…

After one loop with h=0.05h = 0.05 s (251 steps):

rr (rad/s)largest sampled angle rateEuler-angle errorquaternion error
0.0212.3 rad/s0.0021∘0.0021^\circ7.3×10−87.3\times10^{-8} deg
0.00542.2 rad/s0.2816∘0.2816^\circ7.3×10−87.3\times10^{-8} deg
0.001200.3 rad/s7.3353∘7.3353^\circ7.3×10−87.3\times10^{-8} deg

The quaternion error does not depend on rr. The Euler-angle error depends on whether fixed steps resolve a spike about r/q2r/q^2 long, and it is erratic: 0.41∘0.41^\circ at r=0.0005r = 0.0005, less than at 0.0010.001, because the steps land differently on the narrower spike. At r=0.001r = 0.001 the right-hand aircraft visibly ends off its outline; at 0.0050.005 the 0.28∘0.28^\circ is too small to see, so read the label. An adaptive step (4.4) would chase the spike; quaternions have none.

Computing it

🐍 PythonLab: rotation matrices, non-commuting turns, and the light aircraft's principal axes
⌘/Ctrl + Enter
🧪 Coding exerciseExercise: Euler's equations with a quaternion, then Euler angles through a loop
⌘/Ctrl + Enter

Graded: energy to 10−710^{-7} and world L\mathbf L to 10−610^{-6} over 10 s of the flipping box, the flip, ψ˙=57.296\dot\psi = 57.296 rad/s at 89.9∘89.9^\circ, and the loop at r=0.001r = 0.001, h=0.05h = 0.05: quaternion within 10−510^{-5} degrees, Euler angles more than 1∘1^\circ off (7.34∘7.34^\circ, as in the table).

Concept checks

✅ Concept check

A box with $I = (5, 10, 13)/1200$ kg m$^2$ spins at $\Omega = 2\pi$ rad/s about its intermediate axis. What is the e-folding time of a small perturbation, in seconds?

✅ Concept check

At pitch $\theta = 89^\circ$ and zero roll the body yaws at $r = 0.1$ rad/s. What is the heading rate $\dot\psi$, in rad/s?

✅ Concept check

RK4 on $\dot q = \tfrac12 q\otimes(0, \boldsymbol\omega)$ lets $|q|$ drift. Why does renormalising each step not change the attitude the sim draws?

✅ Concept check

A satellite spins about its minimum-inertia axis and slowly dissipates energy with no external torque. Where does it end up?

Problems

✏️ Pen & paperGimbal lock as a determinant●●○

(a) Show that the matrix taking (ϕ˙,θ˙,ψ˙)(\dot\phi, \dot\theta, \dot\psi) to (p,q,r)(p, q, r) has determinant cos⁡θ\cos\theta. (b) At θ=90∘\theta = 90^\circ find a nonzero angle-rate vector giving p=q=r=0p = q = r = 0 and interpret it. (c) Which body rates are then unreachable?

Show worked solution

(a) Expand along the first column: cos⁡ϕ⋅cos⁡ϕcos⁡θ+sin⁡ϕ⋅sin⁡ϕcos⁡θ=cos⁡θ\cos\phi\cdot\cos\phi\cos\theta + \sin\phi\cdot\sin\phi\cos\theta = \cos\theta.

(b) With sin⁡θ=1\sin\theta = 1, cos⁡θ=0\cos\theta = 0 the matrix is [10−10cos⁡ϕ00−sin⁡ϕ0]\begin{bmatrix}1&0&-1\\0&\cos\phi&0\\0&-\sin\phi&0\end{bmatrix}, whose kernel contains (1,0,1)(1, 0, 1). With the nose vertical, yaw about world zz and roll about the nose are the same motion, so equal rates of both cancel.

(c) The column space is spanned by (1,0,0)(1, 0, 0) and (0,cos⁡ϕ,−sin⁡ϕ)(0, \cos\phi, -\sin\phi); the body rate (0,sin⁡ϕ,cos⁡ϕ)(0, \sin\phi, \cos\phi), perpendicular to both, cannot be produced. Near the lock it needs angle rates of order 1/cos⁡θ1/\cos\theta.

✏️ Pen & paperQuaternion bookkeeping●○○

(a) Write the quaternions for a 90∘90^\circ roll and a 90∘90^\circ yaw. (b) Multiply them in both orders and find where the nose goes. (c) What is a 360∘360^\circ roll, and why is it still the identity?

Show worked solution

(a) qx=(22,22,0,0)q_x = (\tfrac{\sqrt2}2, \tfrac{\sqrt2}2, 0, 0), qz=(22,0,0,22)q_z = (\tfrac{\sqrt2}2, 0, 0, \tfrac{\sqrt2}2).

(b) qz⊗qx=12(1,1,1,1)q_z\otimes q_x = \tfrac12(1, 1, 1, 1), a 120∘120^\circ turn about (1,1,1)/3(1, 1, 1)/\sqrt3 sending x→yx \to y: nose east (roll first). qx⊗qz=12(1,1,−1,1)q_x\otimes q_z = \tfrac12(1, 1, -1, 1) sends x→zx \to z: nose down (yaw first). Only the u1×u2\mathbf u_1\times\mathbf u_2 term differs, and it flips sign with the order.

(c) (cos⁡180∘,sin⁡180∘,0,0)=(−1,0,0,0)(\cos180^\circ, \sin180^\circ, 0, 0) = (-1, 0, 0, 0). The two signs cancel in q⊗v⊗q∗q\otimes\mathbf v\otimes q^*, so −q-q is the same rotation as qq.

Key Takeaways

  • A rotation matrix’s columns are the body axes in world coordinates: RTR=IR^{\mathsf T}R = I, det⁡R=1\det R = 1. Order matters: roll then yaw leaves the nose east, yaw then roll points it down.
  • Euler-angle kinematics have determinant cos⁡θ\cos\theta: at pitch 89.9∘89.9^\circ a 0.10.1 rad/s yaw demands 57.357.3 rad/s of ψ˙\dot\psi. Gimbal lock lives in the coordinates.
  • Unit quaternions compose by multiplication, double-cover the rotations and obey q˙=12q⊗(0,ω)\dot q = \tfrac12q\otimes(0, \boldsymbol\omega) with no singularity.
  • L=Iω\mathbf L = I\boldsymbol\omega; the symmetric II has orthogonal eigenvectors, the principal axes. Light aircraft (lumped): 1521.81521.8, 2462.02462.0, 3618.73618.7 kg m2^2.
  • Torque-free, EE and L\mathbf L are conserved: free checks. RK4 (h=0.01h = 0.01 s) keeps EE to 4×10−94\times10^{-9} over 20 s; splitting keeps L\mathbf L to round-off.
  • The intermediate axis is a saddle: the box e-folds in 0.3310.331 s and flips every 4.074.07 s at one turn per second. Dissipation (Explorer 1) destabilises the minimum axis too.
  • Next, 12.4: rotation is now in hand. The six-degree-of-freedom model joins it to the forces and moments of lift (12.1, 12.2) in twelve states, position, velocity, attitude and body rates, advanced by one RK4 loop.
Finished this lesson?

Mark it complete to track your progress (saved in this browser). Reading every section does this for you.

Where this leads

These later lessons build directly on this one: