2D Direction Cosine Matrix#

A Direction Cosine Matrix (DCM) rotates the components of a vector between two reference frames without moving the vector itself. The 2D version is the cleanest place to build that intuition: one frame stays fixed, the other rotates by an angle \(\theta\), and the same physical vector \(\mathbf{v}\) sits unchanged in space; only its component representation changes.

The convention#

This course uses the “components from frame a to frame b” convention:

\[\begin{split} \mathbf{v}^b = \mathbf{C}_a^b(\theta)\,\mathbf{v}^a, \qquad \mathbf{C}_a^b(\theta) = \begin{bmatrix} \cos\theta & \sin\theta \\ -\sin\theta & \cos\theta \end{bmatrix}. \end{split}\]

\(\mathbf{v}^a\) are the components of \(\mathbf{v}\) expressed in frame a; \(\mathbf{v}^b\) are the components of the same physical \(\mathbf{v}\) in frame b. As \(\theta\) changes, the b-frame’s axes rotate, so the components in that rotating frame change, but the physical vector itself never moves.

Interactive demo#

Open in full screen

Walkthrough#

Try the following sequence to build intuition:

  1. Read the opening view, \(\theta = 30°\). The blue b-frame is rotated 30° counterclockwise from the gray a-frame; the navy arc from a-x to b-x marks the angle and its positive direction. The readout shows the live matrix \(\mathbf{C}_a^b(30°) = \begin{bmatrix} 0.866 & 0.500 \\ -0.500 & 0.866 \end{bmatrix}\) and the product \(\mathbf{v}^b = \mathbf{C}_a^b(30°)\,\mathbf{v}^a = [3.098, -0.634]^\top\) for the default \(\mathbf{v}^a = [3, 1]^\top\).

  2. Click the “0°” preset, then “30°” again. At 0° the b-frame lies on the a-frame, \(\mathbf{C}_a^b = \mathbf{I}\), and \(\mathbf{v}^b = \mathbf{v}^a = [3, 1]^\top\). Back at 30°, the brown vector hasn’t moved, but its components have: more along b-x (3.098 vs 3), and a small negative b-y component, because v now sits on the negative-b-y side of the b-x axis.

  3. Click “90°.” The b-x axis now points where a-y points, and b-y points opposite a-x. With the default \(\mathbf{v}^a = [3, 1]^\top\) this gives \(\mathbf{v}^b = [1, -3]^\top\): a quarter-turn of the components.

  4. Press “Play.” The b-frame rotates continuously. Watch the \(\Delta = \lVert\mathbf{v}^b\rVert - \lVert\mathbf{v}^a\rVert\) readout. It shows the raw floating-point difference: exactly 0 at most angles and a few \(\times 10^{-16}\) at others (among the presets, \(+4.4\times10^{-16}\) at 60° and \(-4.4\times10^{-16}\) at 150°). That round-off-sized \(\Delta\) is the numerical signature of an orthonormal DCM. The check line above it confirms the same thing directly: \(\mathbf{C}^\top\mathbf{C} = \mathbf{I}\), \(\det\mathbf{C} = +1\), and \((\mathbf{C}_a^b)^\top\mathbf{v}^b = \mathbf{v}^a\) (the inverse is the transpose). Moving the slider or clicking a preset stops playback.

  5. Read the components off the picture. Dashed drop-lines run from the tip of v perpendicular to each b-axis, and the shaded bands from the origin to each foot have the lengths \(v^b_x\) and \(v^b_y\), labeled on the plot (3.10 and −0.63 at 30°). Each component is \(\lVert\mathbf{v}\rVert\) times a direction cosine: \(v^b_x = \lVert\mathbf{v}\rVert\cos\alpha\) and \(v^b_y = \lVert\mathbf{v}\rVert\sin\alpha\), where \(\alpha\) is the angle from b-x to v (\(-11.6°\) at 30°; the line under the readout states it for the current angle). Head-to-tail, the b-x band plus the drop-line from its foot land exactly on the tip of v: the b-frame components rebuild the same physical vector. Uncheck “Show the components of v along the b-axes” to hide them.

  6. Edit \(\mathbf{v}^a\). Change x and y (each is clamped to ±4 so the vector stays on the canvas). Repeat the rotation experiments and observe that the magnitudes always agree.

Key observations#

  • \(\lVert\mathbf{v}^a\rVert = \lVert\mathbf{v}^b\rVert\) at every \(\theta\), to machine precision. Norm preservation is the simplest unit test you can run on any DCM implementation: rotate a vector, check the norm. If it changed, the matrix is not orthonormal, typically because of one wrong sign or one mistyped entry. The test has a blind spot: the transpose \(\mathbf{C}_b^a\) (the rotation the wrong way) is orthonormal too, so it passes. Check one known case as well, such as \(\theta = 90°\) giving \(\mathbf{v}^b = [1, -3]^\top\).

  • At \(\theta = 360°\) you recover \(\mathbf{v}^b = \mathbf{v}^a\) to round-off. \(\cos 360°\) and \(\sin 360°\) are not exactly 1 and 0 in floating point, so \(\mathbf{v}^b\) still differs from \(\mathbf{v}^a\) in the 16th digit, even though the readout shows \([3.000, 1.000]\) and \(\Delta = 0\): the components carry the round-off, and the norm happens to come out exact. A drift much larger than that after a full revolution means something is wrong.

  • Frames are bookkeeping; vectors are real. The same physical \(\mathbf{v}\) has different components in different frames, but the vector, and any frame-invariant quantity such as its norm, is the same regardless of which frame you write it in.

Connection to 3D#

The 2D version exists to make the geometry visible. In 3D, DCMs are 3×3 orthonormal matrices and the same identities hold: \(\lVert\mathbf{v}^b\rVert = \lVert\mathbf{v}^a\rVert\), \(\mathbf{C}^\top\mathbf{C} = \mathbf{I}\), \(\det\mathbf{C} = +1\). The 3D rotation matrices used throughout the rest of the course (between body, NED, ECEF, and ECI frames) are direct generalizations. Block 2 starts using them in earnest for inertial-error mechanization.

Source#

MATLAB bundle · demos/DcmExample.m↓