3.5.3 · D3Guidance, Navigation & Control (GNC)

Worked examples — Direction cosine matrix (DCM) — construction from Euler angles

2,251 words10 min readBack to topic

The scenario matrix

Every DCM problem is one (or a blend) of these cells. The worked examples below each announce which cell they cover.

Cell What makes it special Where the trouble hides Example
A. Zero input all angles should give identity — a sanity anchor Ex 1
B. Single axis, positive one angle , others sign convention of Ex 2
C. Single axis, negative one angle does flip the right off-diagonal? Ex 3
D. Quadrant / large angle angle (e.g. ) signs; which quadrant Ex 4
E. Full 3-2-1, all nonzero yaw, pitch, roll all active matrix-multiply order, cross terms Ex 5
F. Inverse problem given , find angles atan2 quadrants, range Ex 6
G. Degenerate: gimbal lock pitch angles not unique; Ex 7
H. Word problem (real GNC) rotate a sensor vector frame direction; forward vs inverse Ex 8
I. Exam twist: orthonormality prove/exploit trusting instead of re-inverting Ex 9

We use the shorthand from the parent: , . Angles: yaw about axis 3, pitch about axis 2, roll about axis 1. All matrices transform inertial → body: .


Example 1 — Cell A: the zero rotation

Forecast: guess before reading — if the body hasn't turned at all, what should the DCM be, and what should happen to the vector?

  1. Plug into each elementary matrix. With every angle : , so (the identity). Why this step? The elementary matrices reduce to identity because their entries vanish and their entries become — this is the baseline every other case is measured against.
  2. Multiply. . Why this step? Multiplying by identity changes nothing; a "no turn" attitude must be .
  3. Apply. .

Verify: if the frames coincide, the same physical vector has the same components in both. It does. ✔


Example 2 — Cell B: single-axis positive yaw

Forecast: after turning the body left by , will the old North axis appear to the body slightly right (negative ) or left?

  1. Only survives. with , . Why this step? Pitch and roll matrices are identity, so the product collapses to the single yaw block.
  2. Apply to . Row by row: , , . Why this step? The transform reads off "how much of inertial lies along each body axis." The negative says the old North now lies partly along body .
Figure — Direction cosine matrix (DCM) — construction from Euler angles

Figure: The gray axes () are the fixed inertial frame; the blue axes () are the body, turned counter-clockwise. What to notice: the fixed North arrow has a large positive projection onto (orange dashed, ) and a negative projection onto (red dashed, ). Turning the body CCW makes the fixed vector appear to lean the other way — into the body's half.

Verify: length preserved? . ✔ The signs match the figure: the body turns (CCW), so the fixed North vector's body-frame coordinates rotate . ✔


Example 3 — Cell C: single-axis NEGATIVE roll

Forecast: the parent's has in the top-right of its lower block. With a negative angle, which off-diagonal entry becomes negative?

  1. Substitute . (cosine is even), (sine is odd). Why this step? Cosine ignores the sign of the angle; sine flips it. So the two entries in swap sign relative to .
  2. Write the matrix. Why this step? Row 2 gets in the third slot; row 3 gets .
  3. Apply to . , , .

Verify: length . ✔ A negative roll tips the body so the inertial picks up a component — consistent with rolling the "up" direction toward you. ✔


Example 4 — Cell D: obtuse-angle yaw (quadrant care)

Forecast: is in the second quadrant. Guess the signs of and before computing.

  1. Evaluate the trig. (second quadrant: cosine negative), (sine positive). Why this step? Past the cosine goes negative — a case single-axis-small-angle intuition can miss. Getting the quadrant right is the whole point of this cell.
  2. Matrix. .
  3. Apply to . , , .

Verify: length ✔. The old North now points into the body's third quadrant () — exactly where a body turn should send it. ✔


Example 5 — Cell E: full 3-2-1, all angles nonzero

Forecast: the parent noted is untouched by yaw and roll. Predict before computing.

  1. Read off from the closed form. From the parent's full matrix, . Why this step? This entry depends on pitch alone — a free sanity anchor independent of the messy cross terms.
  2. Read off . . Why this step? mixes roll and pitch only (no yaw) — a second, independent anchor to catch multiply errors.
  3. Cross-check by multiplying. Form first, then premultiply by , and read the same two entries. Why this step? If the closed-form shortcut and the brute-force product agree, our order-of-multiplication (last rotation leftmost) is correct.

Verify: brute-force multiply gives , — matching steps 1–2. The full matrix (used again in Example 6) is


Example 6 — Cell F: the inverse problem (recover angles)

Forecast: which entry gives pitch directly, and why must we use atan2 rather than plain ?

  1. Pitch from . . Why this step? , so inverts it. returns — the valid pitch range for 3-2-1, so no quadrant ambiguity here.
  2. Yaw from . . Why this step? Plain can't tell from (tan repeats every ). atan2 takes both numerator and denominator signs, pinning the correct quadrant.
  3. Roll from . . Why this step? and ; their ratio is , and the shared positive factor means atan2 reads the correct quadrant straight off. Both entries positive ⇒ first-quadrant roll ⇒ .

Verify: the recovered triple is exactly the Example-5 input. Round-trip closed. ✔


Example 7 — Cell G: gimbal lock (degenerate pitch)

Forecast: with , how many independent numbers can survive in the matrix — three angles' worth, or fewer?

  1. Collapse the matrix with . Substituting into the parent's full 3-2-1 form kills every term carrying a factor. What remains depends on yaw and roll only through their difference . (For 3-2-1 at the surviving off-diagonal entries are and .) Why this step? When the yaw axis (3) and roll axis (1) line up along the same physical direction, so only one combined turn is observable.
  2. Case : here . Plugging in gives Why this step? Writing the actual numbers lets us see the collapse: the entire first row is , fixed by pitch alone.
  3. Case : here — different! Pick instead so . With the same difference : Why this step? Two different angle pairs, and , share the difference , so they produce the identical matrix. One matrix, many labels ⇒ the parameterization is singular. The DCM is perfectly healthy; only the Euler names break. This is why GNC stores attitude as quaternions.

Verify: every entry of equals the corresponding entry of . ✔


Example 8 — Cell H: real GNC word problem

Forecast: a pitch tips the nose all the way up. Guess where a straight-up star lands in body coordinates before computing.

  1. Build . With : ; with : ; . Why this step? Sensors live in the body frame; guidance gives the star in inertial. The DCM is the translator, applied in the forward direction .
  2. Apply to . The third column of is what multiplies the -component; it equals . Why this step? Multiplying a matrix by just picks out its third column — a shortcut worth remembering.
  3. Read the result. : the star lies along the body axis.

Verify: length ✔. Physically: pitching the nose up by swings the body -axis to point where "up" was, so the up-star sits along (behind the nose direction). ✔


Example 9 — Cell I: exam twist, exploit

Forecast: the naive move is Gaussian elimination on . The parent gave a shortcut — what is it?

  1. Recall the property. For any DCM, (orthonormality). So . Why this step? Transposing is free (swap rows/columns); inverting a general costs real work. Trusting orthonormality is the whole exam trick.
  2. Transpose . . Why this step? The and swap positions — that IS the inverse rotation , which makes sense: undoing a yaw is a yaw.
  3. Apply. .

Verify: confirm : ? Row1: ✔; Row2: ✔. Round-trip holds. ✔


Recall One-line self-test for each cell

Zero input → identity ::: , vector unchanged. Negative angle → which entries flip? ::: only the two entries (cos is even, sin is odd). Obtuse yaw () → sign of ? ::: negative (second quadrant). Inverse problem → why atan2 not arctan? ::: tan repeats every ; atan2 uses both signs to fix the quadrant. Gimbal lock condition ::: pitch , so and yaw & roll merge onto one axis — only survives. Undo a DCM cheaply ::: use , since .

Connections

  • 3.5.03 Direction cosine matrix (DCM) — construction from Euler angles (Hinglish)
  • Quaternions — avoiding gimbal lock
  • Euler angles — kinematic differential equations
  • Rotation group SO(3) and orthogonal matrices
  • Attitude determination — TRIAD & QUEST
  • Kalman filter — linearized attitude error state
  • Angular velocity and skew-symmetric matrices