3.5.3 · D2Guidance, Navigation & Control (GNC)

Visual walkthrough — Direction cosine matrix (DCM) — construction from Euler angles

2,221 words10 min readBack to topic

Step 1 — What a "frame" is, and what we are trying to translate

WHAT. A frame is just three arrows glued together at a point, each at a right angle to the other two, each of length 1. We draw two frames on top of each other:

  • the navigation frame — arrows (think: North, East, Down — fixed to the world),
  • the body frame — arrows (bolted to the spacecraft, so they turn with it).

The little hat just means "this arrow has length 1" (a unit vector). The subscript () numbers the three arrows.

WHY. A physical direction in space — say "the Sun is that way" — has different lists of numbers in each frame. The whole job of a DCM is to convert one list into the other. Before we can build the converter we must see the two frames and the angle between their arrows.

PICTURE. In the figure the body frame (magenta) is turned relative to the navigation frame (violet). The orange angle is the angle between and . Keep your eye on that angle — it becomes the first number in our matrix.

Figure — Direction cosine matrix (DCM) — construction from Euler angles

Step 2 — Why a dot product is a cosine (earning our main tool)

WHAT. We must justify the tool we just used: why does equal a cosine?

WHY this tool and not another? We want a single number that says "how aligned are two directions?" — big when parallel, zero when perpendicular, negative when opposing. The dot product is the operation with exactly that behaviour, and for unit-length arrows it collapses to a pure cosine with no leftover scaling. That is why the matrix is made of cosines, not tangents or something else.

PICTURE. Drop arrow as a shadow onto arrow . The shadow's length is . That shadow length is the entry.

Figure — Direction cosine matrix (DCM) — construction from Euler angles

Step 3 — One rotation in a plane (the atom of the whole machine)

WHAT. Forget 3D for a moment. Spin the frame by angle about the -axis (the vertical arrow). The -axis does not move; only arrows and swing in their shared plane. We find the new coordinates of a fixed point.

WHY. The full DCM is built only from single-axis spins like this one. If we nail one, we get all three by relabeling axes. This is the atom; Steps 5–6 assemble the molecule.

PICTURE. A point sits at radius , at angle from the old -axis. We rotate the axes forward by . Relative to the new axes the point now sits at angle (it appears to swing backward by ).

Figure — Direction cosine matrix (DCM) — construction from Euler angles

Step 4 — Packaging the spin as a matrix

WHAT. Stack the two equations (plus the untouched -axis) into a grid — a matrix. A matrix here is just a bookkeeping table: row tells you how to build new-coordinate out of the old coordinates.

WHY a matrix? Because chaining rotations then becomes multiplying tables, and multiplication has a fixed, unambiguous order. That order will encode the physical order of the turns (Step 5).

PICTURE. The figure colour-codes where each term from Step 3 lands: top-right, below the diagonal, the lone in the corner for the axis we spun about.

Figure — Direction cosine matrix (DCM) — construction from Euler angles

Step 5 — Why we multiply, and in exactly which order

WHAT. A 3-2-1 sequence means: first yaw about axis , then pitch about the new axis , then roll about the newest axis . Each turn starts from the frame the previous turn left behind.

WHY the order flips. Read the chain of frames: . A vector's nav-coordinates get hit by first, then the result by , then by . Because the operation applied first must sit closest to the vector (rightmost), the physical order writes as:

PICTURE. The figure shows the frame stepping through the three turns, and beside it the matrix product growing leftward — first turn on the right, last turn on the left.

Figure — Direction cosine matrix (DCM) — construction from Euler angles

Step 6 — Carrying out the multiplication, block by block

WHAT. Multiply first, then premultiply by . Matrix multiply = "row of the left table dotted with column of the right table."

WHY in this grouping. Doing first isolates the yaw+pitch block; then 's terms stir roll into the lower two rows only (roll leaves row 1 alone). That is why the top row of the final matrix contains no at all — a fact you can check at a glance.

PICTURE. The figure highlights the top row (pure pitch-yaw, orange) versus the lower two rows (roll-mixed, magenta), so you can see where does and does not appear.

Figure — Direction cosine matrix (DCM) — construction from Euler angles

Step 7 — The degenerate case: gimbal lock at pitch

WHAT. Set , so . The matrix collapses and the yaw column and roll pattern start doing the same job.

WHY it breaks. When the body pitches straight up by , the yaw axis (originally vertical) and the roll axis (now vertical) point the same physical way. Turning either one spins the body about the same line, so two different angle-pairs produce identical attitudes — a whole degree of freedom vanishes. The DCM itself stays a perfectly good rotation; it is the angle labels that go singular.

PICTURE. The figure shows the yaw and roll arrows merging into one vertical line at — you can twist or and the body responds identically.

Figure — Direction cosine matrix (DCM) — construction from Euler angles

Step 8 — The small-angle limit: the DCM becomes minus a skew matrix

WHAT. Let all three angles be tiny. Then , the angle itself (in radians), and any product of two small angles is negligible.

WHY this limit matters. Near the identity, attitude errors are tiny. This linearised form is the entire foundation of the linearized error-state filter used on real spacecraft.

PICTURE. The figure overlays the exact rotation against its straight-line small-angle approximation — they hug near zero and only peel apart for large angles.

Figure — Direction cosine matrix (DCM) — construction from Euler angles

The one-picture summary

Figure — Direction cosine matrix (DCM) — construction from Euler angles

The whole derivation in one arc: two frames → dot product gives cosines → one planar spin → package as → three spins chained (last leads) → the full → its two limits (gimbal lock and small-angle).

Recall Feynman retelling of the walkthrough

Two people describe the same paper airplane; one has spun around. To translate "the nose points there," we ask a simple question over and over: how much of your arrow lies along my arrow? — and the answer is always a cosine (the shadow of one arrow on another). We first learn to spin a flat map by one angle and write down the new left/right/up numbers; that little turn-table is . Since a spacecraft turns three times — spin, tilt nose, roll wings — we stack three of these tables. The catch: the last turn goes at the front of the multiplication, because the vector meets the first turn first. Multiply them out and the big DCM appears, with pitch sitting alone in the top-right corner as our checkpoint. Push pitch to straight-up and two of the turns fight over the same axis (gimbal lock); shrink all turns to whispers and the whole table becomes "identity minus a tiny skew nudge," which is how flight computers track attitude drift.

Recall

Why is every DCM entry a cosine? ::: Each entry is a dot product of two unit vectors, and a dot product of unit vectors equals the cosine of the angle between them. In a 3-2-1 product, which physical turn is the leftmost matrix? ::: The last one (roll, ) — because the first turn must act on the vector first, so it sits rightmost. Why does contain no roll or yaw? ::: Roll () leaves the top row untouched and 's yaw does not reach that corner, so pitch alone sets it — a built-in sanity check. What physically happens at gimbal lock? ::: At the yaw and roll axes align, so only matters and one degree of freedom is lost. In the small-angle limit, why does turn order stop mattering? ::: Products of small angles are dropped, leaving ; to first order rotations commute.

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
  • Angular velocity and skew-symmetric matrices
  • Kalman filter — linearized attitude error state