3.5.10Guidance, Navigation & Control (GNC)

Converting between DCM, quaternions, Euler angles

1,835 words8 min readdifficulty · medium

Three ways to say the same thing: "how is frame B rotated relative to frame A?" The trick is knowing how to translate between the three languages without losing information (gimbal lock, sign flips, normalization drift).


1. The anchor: axis–angle (everything derives from this)

WHY start here? Because both DCM and quaternion have a clean formula from axis–angle, so we derive both, then compose them.

HOW we got the three terms (Why each step?): decompose v\vec v into a part along e^\hat e (unchanged) and perpendicular. The perpendicular part rotates in its plane; cosΦ\cos\Phi keeps it, e^×v\hat e\times\vec v gives the 90°90°-rotated companion scaled by sinΦ\sin\Phi. The along-axis part is restored by the last term.


2. DCM ⇄ Quaternion

Figure — Converting between DCM, quaternions, Euler angles

3. Euler angles (3-2-1 aerospace / yaw-pitch-roll)


Worked examples


Common mistakes


Flashcards

Euler's rotation theorem states
any orientation = a single rotation by angle Φ\Phi about one fixed axis e^\hat e.
Why does the quaternion use half the rotation angle?
the sandwich product qvq1qvq^{-1} applies the rotation twice, so half-angle cancels the doubling (also makes q,qq,-q identical rotations).
DCM→quaternion, why divide by the largest qiq_i?
to avoid dividing by ~0 when that component is small (e.g. q00q_0\approx0 near 180°180°); Shepperd's method.
What isolates the quaternion vector part from a DCM?
the antisymmetric part: C23C32=4q0q1C_{23}-C_{32}=4q_0q_1, etc.
Trace of C(q)C(q) equals?
4q0214q_0^2-1, giving q0=121+trCq_0=\tfrac12\sqrt{1+\text{tr}\,C}.
What is gimbal lock, in the 3-2-1 sequence?
at pitch θ=±90°\theta=\pm90° two axes align; yaw and roll become indistinguishable (only ϕ±ψ\phi\pm\psi determined).
Why atan2 instead of atan for Euler extraction?
atan2 keeps sign of both arguments → correct quadrant over full [π,π][-\pi,\pi].
Best way to convert quaternion↔Euler?
go through the DCM as a neutral hub (fewer error-prone formulas).
q0=cos(Φ/2)q_0=\cos(\Phi/2) and (q1,q2,q3)=?(q_1,q_2,q_3)=?
e^sin(Φ/2)\hat e\sin(\Phi/2).
Do qq and q-q give the same DCM?
yes (map is quadratic in qq).
Why renormalize quaternions each integration step?
drift makes q1\|q\|\ne1, breaking orthonormality of C(q)C(q).

Recall Feynman: explain to a 12-year-old

Imagine a toy plane. There are three ways to describe which way it's pointing: (1) write down a little table saying where its nose, wing and belly point (that's the matrix) — very complete but lots of numbers; (2) a magic set of four numbers that never get confused even when the plane loops upside down (quaternion); (3) three plain words — how much it's turned left, tilted up, and rolled sideways (Euler angles) — easy to say but they get "stuck" when the plane points straight up. Converting is just rewriting the same pointing-direction in another one of these languages. You go through the table (matrix) as your common dictionary.

Connections

Concept Map

guarantees

Rodrigues formula

half-angle

substitute into Rodrigues

Shepperd trick

recover

used to

used to

used to

suffers from

avoids

Axis-angle e, Phi

Euler rotation theorem

DCM C 3x3 matrix

Quaternion q0..q3

Euler angles roll pitch yaw

Rotate vectors

Propagate attitude

Report to human

Gimbal lock singularity

Shepperd trick via trace

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, ek rotation ek hi physical baat hai — "frame B, frame A ke respect me kitna ghooma hai." Bas usko likhne ke teen tareeke hain. DCM ek 3x3 matrix hai, poori honest info deta hai aur vectors ko seedha rotate karta hai, lekin 9 numbers bhaari lagte hain. Quaternion char numbers ka jaadu hai — koi singularity nahi, isliye time ke saath attitude propagate karne ke liye best. Euler angles (roll, pitch, yaw) insaan ke liye padhne me easy, par gimbal lock pe "phas" jaate hain.

Convert karna matlab same rotation ko doosri language me likhna. Sabse smart trick: hamesha DCM ko hub banao. Quaternion se Euler chahiye? Pehle quaternion se DCM, phir DCM se Euler. Isse kam formula yaad karne padte hain aur galti ka chance kam. Quaternion me half-angle (Φ/2\Phi/2) aata hai kyunki sandwich product qvq1qvq^{-1} rotation ko do baar lagata hai — half-angle usko balance karta hai, aur isi wajah se qq aur q-q ek hi rotation dete hain.

Do bade dhyaan ki baatein. Pehla: transpose ki galti mat karo — CC aur CC^\top opposite direction ke rotation hote hain, convention hamesha likho. Doosra: DCM se quaternion nikaalte waqt agar q00q_0\approx 0 ho (yaani rotation 180°180° ke aas-paas), to sabse bade diagonal element se divide karo (Shepperd method), warna zero se divide ho jaayega.

Euler extract karte time hamesha atan2 use karo, simple atan nahi — warna quadrant galat ho ke 180°180° ka error aa jaata hai. Aur quaternion ko har integration step pe normalize karte raho, warna q\|q\| 1 se hat jaayega aur matrix orthonormal nahi rahega. Yeh chhoti chhoti baatein hi real GNC code me galtiyan rokti hain.

Go deeper — visual, from zero

Test yourself — Guidance, Navigation & Control (GNC)

Connections