Rotation Matrix Construction

This is a quick reference for constructing a rotation matrix in \(SO(3)\), primarily for coordinate frame transformations.

Basic Introduction

A rotation matrix in \(SO(3)\) is a linear transformation between coordinate frames. Let \(\{e\}\) and \(\{b\}\) be two arbitrary Euclidean coordinate frames, and let \(x^e\) and \(x^b\) denote the same vector expressed in each frame, respectively.

The rotation matrix \(R^e_b \in SO(3)\) describes the orientation of frame \(\{b\}\) relative to frame \(\{e\}\). Pre-multiplying a vector expressed in \(\{b\}\) by this matrix yields its representation in \(\{e\}\):

\[x^e = R^e_b \, x^b.\]

Since \(R^e_b \in SO(3)\), its inverse equals its transpose:

\[R^b_e = \left(R^e_b\right)^T.\]

Therefore, \(R^b_e\) transforms a vector from frame \(\{e\}\) into frame \(\{b\}\).

SO(3) Properties

A matrix \(R\) belongs to \(SO(3)\) if and only if it satisfies two conditions:

\[R^T R = I, \qquad \det(R) = +1.\]

The first condition enforces orthonormality of columns (and rows); the second rules out improper rotations (reflections). These constraints imply that each column of \(R\) is a unit vector, and any two distinct columns are mutually orthogonal.

Constructing the Rotation Matrix

The key insight is:

The \(i\)-th column of \(R^e_b\) is the unit vector \(b_i\) expressed in the coordinates of frame \(\{e\}\).

Consider two frames illustrated below, where each \(e_i\) and \(b_i\) is a unit basis vector.

Coordinate frames

To find each column, project \(b_i\) onto each axis of \(\{e\}\) using the dot product:

\[\left(R^e_b\right)_{ji} = e_j \cdot b_i.\]

Inspecting the figure for the example configuration:

  • \(b_1\) is aligned with \(-e_3\), with no projection onto \(e_1\) or \(e_2\):
\[b_1^e = \begin{bmatrix} 0 \\ 0 \\ -1 \end{bmatrix}\]
  • \(b_2\) is aligned with \(-e_2\):
\[b_2^e = \begin{bmatrix} 0 \\ -1 \\ 0 \end{bmatrix}\]
  • \(b_3\) is aligned with \(-e_1\):
\[b_3^e = \begin{bmatrix} -1 \\ 0 \\ 0 \end{bmatrix}\]

Assembling these column vectors gives the rotation matrix:

\[R^e_b = \begin{bmatrix} b_1^e & b_2^e & b_3^e \end{bmatrix} = \begin{bmatrix} 0 & 0 & -1 \\ 0 & -1 & 0 \\ -1 & 0 & 0 \end{bmatrix}.\]

One can verify the \(SO(3)\) conditions: the columns are mutually orthogonal unit vectors, and \(\det(R^e_b) = +1\).

Interactive Visualizer

The demo below lets you freely orient the body frame \(\{b\}\) relative to the fixed frame \(\{e\}\) using Euler angle sliders. The rotation matrix is updated live, and the bottom panel shows how it transforms an arbitrary vector.

α (Z-axis)
β (Y-axis)
γ (X-axis)
Reb — columns are bi in {e}
Vector transform: xe = R · xb
xb
xe

Drag the sliders to rotate frame {b} relative to {e} using ZYX Euler angles. The matrix columns (colour-coded red/green/blue for b₁/b₂/b₃) update live. Edit xb to see the transformed vector.

Verifying the Result

Given a valid \(R^e_b\), one can verify the \(SO(3)\) conditions numerically:

\(R^T R = I \quad \Longleftrightarrow \quad \text{columns are orthonormal},\) \(\det(R) = +1 \quad \Longleftrightarrow \quad \text{proper rotation (no reflection)}.\)

For the example in the figure:

\[R^e_b = \begin{bmatrix} 0 & 0 & -1 \\ 0 & -1 & 0 \\ -1 & 0 & 0 \end{bmatrix}, \qquad \det(R^e_b) = (-1)\bigl[0\cdot 0 - (-1)(-1)\bigr] = (-1)(-1) = +1. \checkmark\]

Checking orthogonality, \(R^T R = I\) holds since each column is a standard basis vector (up to sign), which are trivially orthonormal.