Niko Natsoulas Home

Attitude Dynamics

Interactively explore spacecraft attitude with quaternions & DCMs

Quaternion (scalar-first)


Direction Cosine Matrix

How to Use This Visualization

Mouse Interaction

  • Click and drag to rotate Sputnik freely
  • Any mouse interaction will stop spinning if active

Quaternion Controls

  • Enter values for the scalar-first quaternion [q₀, q₁, q₂, q₃]
  • Click "Apply Quaternion" to update attitude
  • Use "Zero All" or "Reset to Identity" for quick settings

Direction Cosine Matrix

  • Enter values in the 3x3 DCM grid
  • Click "Apply DCM" to update attitude
  • Use the rotation generators for common DCMs
  • Try different angles for X, Y, and Z axis rotations

Angular Velocity (Spin)

  • Scroll down in the controls panel to find spin options
  • Enter values in deg/s for rotation rates around each axis
  • Use preset buttons for common rotation patterns
  • Click "Start Spin" to begin continuous rotation
  • DCM and quaternion values update in real-time during spin

Spacecraft Attitude Dynamics Concepts

Quaternions

Quaternions are a 4-parameter representation of attitude that avoids the singularities found in Euler angles.

$$\mathbf{q} = q_0 + q_1\mathbf{i} + q_2\mathbf{j} + q_3\mathbf{k} = [q_0, \vec{q}]$$

Where \(q_0\) is the scalar part and \(\vec{q} = [q_1, q_2, q_3]\) is the vector part. For rotation, these relate to axis-angle as:

$$q_0 = \cos\frac{\theta}{2}, \quad \vec{q} = \hat{\mathbf{n}}\sin\frac{\theta}{2}$$

Where \(\hat{\mathbf{n}}\) is the rotation axis and \(\theta\) is the rotation angle.

Direction Cosine Matrix (DCM)

DCM is a 3×3 rotation matrix that transforms vectors from one coordinate system to another.

$$\mathbf{C} = \begin{bmatrix} C_{11} & C_{12} & C_{13} \\ C_{21} & C_{22} & C_{23} \\ C_{31} & C_{32} & C_{33} \end{bmatrix}$$

The columns represent the body coordinate axes expressed in the inertial frame.

From quaternions, the DCM can be computed as:

$$\mathbf{C} = (q_0^2 - \vec{q}^T\vec{q})\mathbf{I}_{3×3} + 2\vec{q}\vec{q}^T - 2q_0[\vec{q}×]$$

Torque-Free Motion

In the absence of external torques, angular momentum is conserved. For a rigid body, this means:

$$\dot{\mathbf{H}} = \mathbf{0}$$

Where \(\mathbf{H}\) is the angular momentum. In body coordinates, this leads to:

$$\mathbf{I}\dot{\boldsymbol{\omega}} + \boldsymbol{\omega} × (\mathbf{I}\boldsymbol{\omega}) = \mathbf{0}$$

Where \(\mathbf{I}\) is the moment of inertia tensor and \(\boldsymbol{\omega}\) is the angular velocity.

Constant Angular Velocity

For bodies with special inertia properties or specific initial conditions, \(\boldsymbol{\omega}\) can remain constant in body coordinates. Our simulation implements:

$$\dot{\boldsymbol{\omega}} = \mathbf{0}$$

This means the spacecraft rotates around a fixed axis with constant speed, even though the orientation changes continuously.

Quaternion Kinematics

For a rotating body with angular velocity \(\boldsymbol{\omega}\), the quaternion evolution is given by:

$$\dot{\mathbf{q}} = \frac{1}{2}\mathbf{q} \otimes \begin{bmatrix} 0 \\ \boldsymbol{\omega} \end{bmatrix}$$

Where \(\otimes\) is quaternion multiplication. This differential equation describes how the orientation changes with time.

DCM Kinematics

The equivalent differential equation for the DCM is:

$$\dot{\mathbf{C}} = -[\boldsymbol{\omega}×]\mathbf{C}$$

Where \([\boldsymbol{\omega}×]\) is the skew-symmetric matrix formed from angular velocity:

$$[\boldsymbol{\omega}×] = \begin{bmatrix} 0 & -\omega_3 & \omega_2 \\ \omega_3 & 0 & -\omega_1 \\ -\omega_2 & \omega_1 & 0 \end{bmatrix}$$

Euler's Rotation Theorem

Any rotation can be expressed as a single rotation about some axis. This is the principle behind the axis-angle representation.

$$\mathbf{R}(\hat{\mathbf{n}}, \theta) = \mathbf{I} + \sin\theta[\hat{\mathbf{n}}×] + (1-\cos\theta)[\hat{\mathbf{n}}×]^2$$

This is the foundation of both quaternion and DCM representations.

Body Frame Axes

The red, green, and blue axes in the visualization represent the body-fixed coordinate frame:

  • X-axis (red) - Body forward direction
  • Y-axis (green) - Body upward direction
  • Z-axis (blue) - Body right direction

This right-handed coordinate system rotates with the spacecraft.

Attitude Propagation

For the constant angular velocity case, the quaternion at time \(t\) is:

$$\mathbf{q}(t) = \mathbf{q}(t_0) \otimes \exp\left(\frac{1}{2}\boldsymbol{\Omega}\Delta t\right)$$

Where \(\boldsymbol{\Omega}\) is a 4×4 matrix formed from angular velocity components and \(\Delta t = t - t_0\).

Polhode Motion

In torque-free rotation, the angular velocity vector traces a path called a polhode when viewed from the body frame.

For principal axis rotation (as simulated here), the polhode simplifies to a single point, meaning \(\boldsymbol{\omega}\) is constant in body coordinates.