Physics Library
 An open source physics library
Encyclopedia | Forums | Docs | Random | Template Test |  
Login
create new user
Username:
Password:
forget your password?
Main Menu
Sections

Meta

Talkback

Downloads

Information
[parent] quaternion exercises for physics and engineering (Example)

Quaternion Exercises for Physics and Engineering

This article is the consolidated self study problem bank for the PhysicsLibrary quaternion series.

The problems are arranged roughly from foundational algebra through engineering attitude propagation. All forty exercises are stated before any solutions so that the article can be used as a genuine problem set.

Unless a problem explicitly states otherwise, use the PhysicsLibrary passive frame convention:

$\displaystyle {}^{B}v = {}^{B}q_A \,{}^{A}v \,({}^{B}q_A)^*,$ (1)
$\displaystyle {}^{B}q_A = \cos\frac{\theta}{2} - \widehat{\mathbf u} \sin\frac{\theta}{2},$ (2)

and Hamilton multiplication

$\displaystyle \mathbf i\mathbf j=\mathbf k. $

Quaternion components are displayed scalar first.

Exercises

Part I: conventions and algebra

  1. Convention identification.

    A software library stores quaternion arrays as

    $\displaystyle [q_x,q_y,q_z,q_w] $

    and documents

    $\displaystyle \mathbf i\mathbf j=\mathbf k. $

    Identify the storage order and multiplication convention. Does the storage order determine whether the quaternion is active or passive?

  2. Hamilton basis products.

    Evaluate

    $\displaystyle \mathbf i\mathbf k, \qquad \mathbf k\mathbf i, \qquad \mathbf j\mathbf i, \qquad \mathbf i\mathbf j\mathbf k, \qquad \mathbf j\mathbf i\mathbf k. $
  3. General quaternion product.

    Let

    $\displaystyle p=1+2\mathbf i-\mathbf j+3\mathbf k $

    and

    $\displaystyle q=2-\mathbf i+4\mathbf j+\mathbf k. $

    Compute $pq$ and $qp$.

  4. Conjugate and product reversal.

    For arbitrary quaternions $p$ and $q$, prove

    $\displaystyle (pq)^*=q^*p^*. $

    Then verify the identity numerically using the quaternions in Exercise 3.

  5. norm and inverse.

    For

    $\displaystyle q=2-\mathbf i+2\mathbf j+2\mathbf k, $

    compute $\lVert q\rVert$, $q^*$, and $q^{-1}$.

    Verify directly that

    $\displaystyle qq^{-1}=1. $
  6. Normalization.

    Normalize

    $\displaystyle q= \begin{bmatrix} 2\ -1\ 2\ 2 \end{bmatrix}. $

    State whether normalization changes the physical rotation axis represented by the vector part.

  7. Double representation.

    Show algebraically that for a unit quaternion,

    $\displaystyle (-q)v(-q)^* = qvq^*. $

    Explain the geometric meaning.

  8. Pure quaternion square.

    Let

    $\displaystyle u=a\mathbf i+b\mathbf j+c\mathbf k, \qquad a^2+b^2+c^2=1. $

    Prove

    $\displaystyle u^2=-1. $

Part II: axis angle and passive vector transformations

  1. Positive $90^\circ$ frame rotation about $+z$.

    Construct ${}^{B}q_A$ for a positive $90^\circ$ frame rotation about $+\widehat{\mathbf z}$.

  2. Arbitrary axis construction.

    Construct the passive quaternion for a positive $60^\circ$ frame rotation about

    $\displaystyle \widehat{\mathbf u} = \frac13 \begin{bmatrix} 1\\ 2\\ 2 \end{bmatrix}. $
  3. Passive coordinate transformation.

    Using the quaternion from Exercise 9, transform the fixed physical vector

    $\displaystyle {}^{A}\mathbf v = \begin{bmatrix} 1\\ 0\\ 0 \end{bmatrix}$

    into $B$ coordinates.

  4. Passive Rodrigues formula.

    Starting from

    $\displaystyle q = \cos\frac{\theta}{2} - \widehat{\mathbf u} \sin\frac{\theta}{2}, $

    derive

    $\displaystyle \mathbf v_B = \mathbf v_A\cos\theta - (\widehat{\mathbf u}\times\... ...eta + \widehat{\mathbf u} (\widehat{\mathbf u}\cdot\mathbf v_A) (1-\cos\theta).$ (3)
  5. Extract axis and angle.

    Given

    $\displaystyle q = \begin{bmatrix} \frac{\sqrt2}{2}\ -\frac{\sqrt6}{6}\ -\frac{\sqrt6}{6}\ -\frac{\sqrt6}{6} \end{bmatrix}, $

    recover the positive physical frame rotation axis and angle.

  6. Small frame rotation.

    For

    $\displaystyle \delta\boldsymbol\theta = \begin{bmatrix} 0.010\ -0.020\ 0.030 \end{bmatrix}\mathrm{rad}, $

    form the first order passive small rotation quaternion.

  7. Active versus passive diagnostic.

    A positive $90^\circ$ geometric rotation about $+z$ is represented by the active rotor

    $\displaystyle q_a=\frac{1+\mathbf k}{\sqrt2}. $

    Write the passive frame quaternion for the same geometry and state the relationship between the two.

  8. Finite frame chain.

    Suppose

    $\displaystyle {}^{B}q_A = \frac{1-\mathbf i}{\sqrt2} $

    and

    $\displaystyle {}^{C}q_B = \frac{1-\mathbf j}{\sqrt2}. $

    Compute ${}^{C}q_A$.

Part III: composition, DCMs, and Euler angles

  1. Noncommuting order.

    Using

    $\displaystyle q_x=\frac{1-\mathbf i}{\sqrt2}, \qquad q_y=\frac{1-\mathbf j}{\sqrt2}, $

    compute $q_yq_x$ and $q_xq_y$. Explain why the results differ.

  2. Quaternion to DCM.

    Convert

    $\displaystyle q = \frac{1-\mathbf k}{\sqrt2} $

    to a direction cosine matrix.

  3. DCM to quaternion.

    Recover a passive unit quaternion from

    $\displaystyle C= \begin{bmatrix} 0&1&0\ -1&0&0\ 0&0&1 \end{bmatrix}. $
  4. DCM column interpretation.

    For the matrix in Exercise 19, interpret each of the three columns geometrically.

  5. Transpose and conjugate.

    Prove

    $\displaystyle C(q^*)=C(q)^T. $

    Interpret this result as a reversal of frame map direction.

  6. Quaternion and DCM composition.

    Show that under the PhysicsLibrary convention

    $\displaystyle C(pq)=C(p)C(q). $

    Use Exercise 16 as a numerical check.

  7. Pure yaw Euler conversion.

    For intrinsic $3$-$2$-$1$ yaw, pitch, roll with

    $\displaystyle \phi=0, \qquad \theta=0, \qquad \psi=60^\circ, $

    compute the passive quaternion.

  8. General $3$-$2$-$1$ quaternion.

    For

    $\displaystyle \phi=20^\circ, \qquad \theta=-10^\circ, \qquad \psi=30^\circ, $

    compute

    $\displaystyle {}^{B}q_A = q_1^P(\phi) q_2^P(\theta) q_3^P(\psi) $

    to at least six decimal places.

  9. Recover Euler Angles.

    Given a passive quaternion with corresponding DCM entries

    $\displaystyle C_{13}=-0.5, \qquad C_{23}=0.4330127, \qquad C_{33}=0.75, $

    $\displaystyle C_{12}=0.75, \qquad C_{11}=0.4330127, $

    recover the principal intrinsic $3$-$2$-$1$ roll, pitch, and yaw angles.

  10. Gimbal lock.

    Explain why the intrinsic $3$-$2$-$1$ representation becomes singular at

    $\displaystyle \theta=\pm90^\circ. $

    What remains well defined?

Part IV: quaternion kinematics and angular velocity

  1. Derivative at the identity.

    For

    $\displaystyle q(0)=1 $

    and constant body resolved angular velocity

    $\displaystyle \omega^B=\Omega\mathbf k, $

    compute $\dot q(0)$.

  2. Body resolved component equations.

    Starting from

    $\displaystyle \dot q=-\frac12\omega^Bq, $

    derive the four scalar component equations.

  3. Norm preservation.

    Prove that the exact continuous quaternion kinematic equation preserves

    $\displaystyle q^Tq=1. $
  4. Exact constant rate propagation.

    Let

    $\displaystyle q(0)=1, \qquad \omega^B= \begin{bmatrix} 1\\ 2\\ 2 \end{bmatrix}\mathrm{rad/s}. $

    Find the exact quaternion at

    $\displaystyle t=0.2\ \mathrm{s}. $
  5. Recover angular velocity.

    Starting from

    $\displaystyle \dot q = -\frac12\omega^Bq, $

    derive $\omega^B$ in terms of $q$ and $\dot q$.

  6. Body versus reference resolved rate.

    Prove that

    $\displaystyle \dot q = -\frac12\omega^Bq = -\frac12q\omega^I $

    when

    $\displaystyle \omega^B=q\omega^Iq^*. $
  7. Forward Euler norm drift.

    With

    $\displaystyle q_k=1, \qquad \omega^B=0.5\mathbf k, \qquad \Delta t=0.1\ \mathrm{s}, $

    compute one forward Euler step and its norm.

  8. DCM kinematics.

    Derive

    $\displaystyle {}^{B}\dot C_I = -[\omega^B]_\times {}^{B}C_I. $

Part V: relative attitude and error quaternions

  1. Left and right errors.

    Given actual attitude $q$ and desired attitude $q_d$, derive

    $\displaystyle \delta q_L=q_dq^* $

    and

    $\displaystyle \delta q_R=q^*q_d. $

    Show how each reconstructs $q_d$.

  2. Same axis attitude error.

    The actual attitude is positive passive yaw $10^\circ$ and the desired attitude is positive passive yaw $25^\circ$.

    Compute the relative quaternion and recover the physical frame error.

  3. Small passive attitude error.

    An error quaternion is locally

    $\displaystyle \delta q \approx \begin{bmatrix} 1\ 0.005\ -0.010\ 0.020 \end{bmatrix}. $

    Recover the first order physical frame error vector.

  4. Transport right error to left error.

    Show that

    $\displaystyle \delta q_L = q\delta q_Rq^*. $

    Then derive the first order vector relation

    $\displaystyle \delta\boldsymbol\theta_L = C(q) \delta\boldsymbol\theta_R. $
  5. Principal sign choice.

    An error calculation returns

    $\displaystyle \delta q = \begin{bmatrix} -0.99904822\ 0\ 0\ 0.04361939 \end{bmatrix}. $

    Select the principal representative and recover the physical frame error.

Part VI: IMU attitude state propagation

  1. Bias corrected IMU update.

    A body gyroscope reports

    $\displaystyle \boldsymbol\omega_m^B = \begin{bmatrix} 0.01\ -0.02\ 0.53 \end{bmatrix}\mathrm{rad/s}, $

    with bias estimate

    $\displaystyle \widehat{\mathbf b}_g = \begin{bmatrix} 0.01\ -0.02\ 0.03 \end{bmatrix}\mathrm{rad/s}. $

    For

    $\displaystyle q_k=1, \qquad \Delta t=0.1\ \mathrm{s}, $

    compute the corrected rate, delta angle, exact passive increment, and $q_{k+1}$.

  2. Body increment multiplication side.

    Use frame labels to prove that a body resolved IMU increment satisfies

    $\displaystyle q_{k+1} = \delta q_Bq_k $

    for $q_k={}^Bq_I$.

  3. Two small increments and coning.

    Two successive body increments are

    $\displaystyle \Delta\boldsymbol\theta_1 $

    and

    $\displaystyle \Delta\boldsymbol\theta_2. $

    Show to second order that the equivalent physical rotation vector is

    $\displaystyle \Delta\boldsymbol\theta_{\mathrm{eq}} \approx \Delta\boldsymbol\t... ...\theta_2 + \frac12 \Delta\boldsymbol\theta_1 \times \Delta\boldsymbol\theta_2. $
  4. Quaternion sign continuity.

    Suppose two successive numerical states satisfy

    $\displaystyle q_{k+1}^Tq_k<0. $

    What operation should be performed if a continuous quaternion time history is desired? Does the operation change physical attitude?

  5. Specific force transformation.

    The attitude state is

    $\displaystyle q={}^Bq_I. $

    An accelerometer measures ${}^B\mathbf f$. Derive the DCM and quaternion expressions for ${}^I\mathbf f$.

  6. Capstone convention audit.

    A legacy routine propagates a quaternion using

    $\displaystyle q_{k+1}=q_k \exp \left( +\frac12 \Delta\boldsymbol\theta^B \right) $

    and labels the state ${}^Bq_I$.

    Identify both convention inconsistencies relative to PhysicsLibrary and write the corrected update.

Solutions

Solution 1: convention identification

The array

$\displaystyle [q_x,q_y,q_z,q_w] $

is scalar last storage.

The rule

$\displaystyle \mathbf i\mathbf j=\mathbf k $

identifies Hamilton multiplication.

Storage order does not determine active versus passive interpretation. That must be defined separately by the frame map and vector transformation law.

Solution 2: Hamilton basis products

Using the Hamilton multiplication table,

$\displaystyle \mathbf i\mathbf k=-\mathbf j, $

$\displaystyle \mathbf k\mathbf i=\mathbf j, $

$\displaystyle \mathbf j\mathbf i=-\mathbf k. $

Also,

$\displaystyle \mathbf i\mathbf j\mathbf k = \mathbf k\mathbf k = -1. $

Finally,

$\displaystyle \mathbf j\mathbf i\mathbf k = (-\mathbf k)\mathbf k = 1. $

Solution 3: general quaternion product

Using scalar vector form or direct expansion,

$\displaystyle p=(1,[2,-1,3]), \qquad q=(2,[-1,4,1]). $

The scalar part of $pq$ is

$\displaystyle 1(2)-[2,-1,3]\cdot[-1,4,1] = 2-(-3) = 5. $

The vector part is

$\displaystyle 1[-1,4,1] + 2[2,-1,3] + [2,-1,3]\times[-1,4,1]. $

The cross product is

$\displaystyle [-13,-5,7]. $

Hence

$\displaystyle pq = 5-10\mathbf i-3\mathbf j+14\mathbf k. $

For $qp$, the cross product reverses sign:

$\displaystyle qp = 5+16\mathbf i+7\mathbf j. $

Solution 4: conjugate and product reversal

Write

$\displaystyle p=p_w+\mathbf p, \qquad q=q_w+\mathbf q. $

Conjugation changes the sign of every vector part. Since Hamilton multiplication contains $\mathbf p\times\mathbf q$, conjugation changes the cross term sign. Reversing factor order also changes the cross term sign because

$\displaystyle \mathbf q\times\mathbf p = -\mathbf p\times\mathbf q. $

Therefore

$\displaystyle (pq)^* = q^*p^*. $

For Exercise 3,

$\displaystyle pq = 5-10\mathbf i-3\mathbf j+14\mathbf k, $

so

$\displaystyle (pq)^* = 5+10\mathbf i+3\mathbf j-14\mathbf k. $

Direct multiplication of $q^*p^*$ gives the same result.

Solution 5: norm and inverse

For

$\displaystyle q=2-\mathbf i+2\mathbf j+2\mathbf k, $

the norm is

$\displaystyle \lVert q\rVert = \sqrt{4+1+4+4} = \sqrt{13}. $

The conjugate is

$\displaystyle q^* = 2+\mathbf i-2\mathbf j-2\mathbf k. $

Therefore

$\displaystyle q^{-1} = \frac{ 2+\mathbf i-2\mathbf j-2\mathbf k }{ 13 }. $

Since

$\displaystyle qq^* = 13, $

we have

$\displaystyle qq^{-1} = \frac{qq^*}{13} = 1. $

Solution 6: normalization

The norm is

$\displaystyle \sqrt{4+1+4+4} = \sqrt{13}. $

Therefore

$\displaystyle \widehat q = \frac{1}{\sqrt{13}} \begin{bmatrix} 2\\ -1\\ 2\\ 2 \end{bmatrix}. $

Normalization rescales all four components by the same positive scalar. It does not change the direction of the vector part, although it does change the half angle implied by a nonunit quaternion if one had incorrectly attempted to interpret the original unnormalized components as a unit rotation.

Solution 7: double representation

Because

$\displaystyle (-q)^* = -q^*, $

we have

$\displaystyle (-q)v(-q)^* = (-q)v(-q^*) = qvq^*. $

Thus $q$ and $-q$ represent the same physical orientation. Unit quaternions double cover the rotation group.

Solution 8: pure quaternion square

Expand

$\displaystyle u^2 = (a\mathbf i+b\mathbf j+c\mathbf k)^2. $

The diagonal terms give

$\displaystyle -a^2-b^2-c^2. $

Every mixed pair cancels because, for example,

$\displaystyle ab(\mathbf i\mathbf j+\mathbf j\mathbf i) = ab(\mathbf k-\mathbf k) = 0. $

Therefore

$\displaystyle u^2 = -(a^2+b^2+c^2) = -1. $

Solution 9: positive $90^\circ$ frame rotation about $+z$

The passive axis angle formula gives

$\displaystyle {}^{B}q_A = \cos45^\circ - \mathbf k\sin45^\circ. $

Hence

$\displaystyle {}^{B}q_A = \frac{1-\mathbf k}{\sqrt2}. $

Solution 10: arbitrary axis construction

The half angle is $30^\circ$, so

$\displaystyle \cos30^\circ=\frac{\sqrt3}{2}, \qquad \sin30^\circ=\frac12. $

Thus

$\displaystyle {}^{B}q_A = \frac{\sqrt3}{2} - \frac12 \left( \frac13\mathbf i+ \frac23\mathbf j+ \frac23\mathbf k \right). $

Therefore

$\displaystyle {}^{B}q_A = \frac{\sqrt3}{2} -\frac16\mathbf i -\frac13\mathbf j -\frac13\mathbf k. $

Solution 11: passive coordinate transformation

From Exercise 9,

$\displaystyle q = \frac{1-\mathbf k}{\sqrt2}. $

The corresponding passive DCM is

$\displaystyle C(q) = \begin{bmatrix} 0&1&0\ -1&0&0\ 0&0&1 \end{bmatrix}. $

Therefore

$\displaystyle {}^{B}\mathbf v = C(q) \begin{bmatrix} 1\\ 0\\ 0 \end{bmatrix}= \begin{bmatrix} 0\\ -1\\ 0 \end{bmatrix}. $

The fixed physical vector has $B$ coordinates along $-\widehat{\mathbf y}$.

Solution 12: passive Rodrigues formula

Let

$\displaystyle q=c-\widehat{\mathbf u}s, \qquad c=\cos\frac{\theta}{2}, \qquad s=\sin\frac{\theta}{2}. $

Expand

$\displaystyle qvq^* = (c-\widehat{\mathbf u}s) v (c+\widehat{\mathbf u}s). $

Using pure quaternion multiplication and collecting vector terms gives

$\displaystyle (c^2-s^2)\mathbf v - 2cs (\widehat{\mathbf u}\times\mathbf v) + 2s^2 \widehat{\mathbf u} (\widehat{\mathbf u}\cdot\mathbf v). $

Use

$\displaystyle c^2-s^2=\cos\theta, $

$\displaystyle 2cs=\sin\theta, $

and

$\displaystyle 2s^2=1-\cos\theta. $

Then

$\displaystyle \mathbf v_B = \mathbf v_A\cos\theta - (\widehat{\mathbf u}\times\... ...ta + \widehat{\mathbf u} (\widehat{\mathbf u}\cdot\mathbf v_A) (1-\cos\theta). $

Solution 13: extract axis and angle

The scalar component is

$\displaystyle q_w=\frac{\sqrt2}{2} = \cos45^\circ. $

Therefore

$\displaystyle \theta = 90^\circ. $

The vector part is

$\displaystyle -\frac{\sqrt6}{6} \begin{bmatrix} 1\\ 1\\ 1 \end{bmatrix}. $

Its norm is

$\displaystyle \frac{\sqrt2}{2}. $

For a passive quaternion, the physical frame axis is opposite the normalized vector part:

$\displaystyle \widehat{\mathbf u} = \frac{1}{\sqrt3} \begin{bmatrix} 1\\ 1\\ 1 \end{bmatrix}. $

Solution 14: small frame rotation

The passive first order small frame quaternion is

$\displaystyle \delta q \approx \begin{bmatrix} 1\ -\frac12\delta\boldsymbol\theta \end{bmatrix}. $

Hence

$\displaystyle \delta q \approx \begin{bmatrix} 1\ -0.005\ 0.010\ -0.015 \end{bmatrix}. $

Solution 15: active versus passive diagnostic

The passive frame quaternion for the same positive geometric frame rotation is the conjugate of the active rotor:

$\displaystyle q_p = q_a^* = \frac{1-\mathbf k}{\sqrt2}. $

Thus

$\displaystyle q_p=q_a^*. $

Solution 16: finite frame chain

The chain is

$\displaystyle {}^{C}q_A = {}^{C}q_B {}^{B}q_A. $

Therefore

$\displaystyle {}^{C}q_A = \frac12 (1-\mathbf j) (1-\mathbf i). $

Since

$\displaystyle \mathbf j\mathbf i=-\mathbf k, $

we obtain

$\displaystyle {}^{C}q_A = \frac12 (1-\mathbf i-\mathbf j-\mathbf k). $

Solution 17: noncommuting order

First,

$\displaystyle q_yq_x = \frac12 (1-\mathbf j)(1-\mathbf i) = \frac12 (1-\mathbf i-\mathbf j-\mathbf k). $

Second,

$\displaystyle q_xq_y = \frac12 (1-\mathbf i)(1-\mathbf j) = \frac12 (1-\mathbf i-\mathbf j+\mathbf k). $

They differ because

$\displaystyle \mathbf i\mathbf j = \mathbf k, \qquad \mathbf j\mathbf i = -\mathbf k. $

Finite rotations about different axes do not commute.

Solution 18: quaternion to DCM

For

$\displaystyle q= \frac{1-\mathbf k}{\sqrt2}, $

we have

$\displaystyle q_w=\frac{\sqrt2}{2}, \qquad q_z=-\frac{\sqrt2}{2}. $

Substitution into the passive quaternion DCM formula gives

$\displaystyle C(q) = \begin{bmatrix} 0&1&0\ -1&0&0\ 0&0&1 \end{bmatrix}. $

Solution 19: DCM to quaternion

The trace is

$\displaystyle 1. $

Hence

$\displaystyle q_w = \frac12\sqrt{1+1} = \frac{\sqrt2}{2}. $

Then

$\displaystyle q_z = \frac{C_{21}-C_{12}}{4q_w} = \frac{-1-1}{4(\sqrt2/2)} = -\frac{\sqrt2}{2}. $

The other vector components are zero.

Thus

$\displaystyle q = \frac{1-\mathbf k}{\sqrt2}. $

The negative quaternion is equally valid.

Solution 20: DCM column interpretation

For

$\displaystyle C= \begin{bmatrix} 0&1&0\ -1&0&0\ 0&0&1 \end{bmatrix}, $

the first column is

$\displaystyle \begin{bmatrix} 0\\ -1\\ 0 \end{bmatrix}, $

so the $A$ frame $x$ basis direction has $B$ coordinates $-\widehat{\mathbf y}_B$.

The second column is

$\displaystyle \begin{bmatrix} 1\\ 0\\ 0 \end{bmatrix}, $

so the $A$ frame $y$ basis direction has $B$ coordinates $+\widehat{\mathbf x}_B$.

The third column is

$\displaystyle \begin{bmatrix} 0\\ 0\\ 1 \end{bmatrix}, $

so the $z$ axes coincide.

Solution 21: transpose and conjugate

The conjugate is the inverse unit quaternion:

$\displaystyle q^*=q^{-1}. $

The DCM of the inverse transformation is the inverse matrix:

$\displaystyle C(q^*) = C(q)^{-1}. $

A proper DCM is orthogonal, so

$\displaystyle C(q)^{-1} = C(q)^T. $

Therefore

$\displaystyle C(q^*)=C(q)^T. $

Quaternion conjugation reverses the passive frame map direction.

Solution 22: quaternion and DCM composition

For any vector,

$\displaystyle C(pq)\mathbf v $

is represented by the quaternion sandwich

$\displaystyle (pq)v(pq)^*. $

Since

$\displaystyle (pq)^*=q^*p^*, $

we have

$\displaystyle (pq)vq^*p^* = p(qvq^*)p^*. $

Thus the transformation associated with $q$ is applied first and the transformation associated with $p$ second. Therefore

$\displaystyle C(pq)=C(p)C(q). $

For Exercise 16,

$\displaystyle C(q_yq_x)=C(q_y)C(q_x), $

which gives the same direct $A\rightarrow C$ frame map.

Solution 23: pure yaw Euler conversion

For a pure yaw,

$\displaystyle {}^{B}q_A = q_3^P(\psi) = \cos\frac{\psi}{2} - \mathbf k\sin\frac{\psi}{2}. $

For

$\displaystyle \psi=60^\circ, $

$\displaystyle {}^{B}q_A = \frac{\sqrt3}{2} - \frac12\mathbf k. $

Solution 24: general $3$-$2$-$1$ quaternion

Using

$\displaystyle {}^{B}q_A = q_1^P(20^\circ) q_2^P(-10^\circ) q_3^P(30^\circ), $

the passive scalar first components are approximately

$\displaystyle {}^{B}q_A \approx \begin{bmatrix} 0.943714\ -0.189308\ 0.038135\ -0.268536 \end{bmatrix}. $

Solution 25: recover Euler angles

For passive intrinsic $3$-$2$-$1$,

$\displaystyle \theta = \arcsin(-C_{13}). $

Thus

$\displaystyle \theta = \arcsin(0.5) = 30^\circ. $

Next,

$\displaystyle \phi = \operatorname{atan2}(C_{23},C_{33}) = \operatorname{atan2}(0.4330127,0.75) = 30^\circ. $

Finally,

$\displaystyle \psi = \operatorname{atan2}(C_{12},C_{11}) = \operatorname{atan2}(0.75,0.4330127) = 60^\circ. $

Therefore

$\displaystyle (\phi,\theta,\psi) = (30^\circ,30^\circ,60^\circ). $

Solution 26: gimbal lock

For intrinsic $3$-$2$-$1$,

$\displaystyle C_{13}=-\sin\theta. $

At

$\displaystyle \theta=\pm90^\circ, $

we have

$\displaystyle \cos\theta=0. $

The matrix entries used to recover roll and yaw lose independent information. The first and third Euler axes become aligned.

The physical attitude remains perfectly well defined. Only the selected Euler coordinate chart becomes singular.

A quaternion representation remains nonsingular.

Solution 27: derivative at the identity

The passive body resolved kinematic equation is

$\displaystyle \dot q = -\frac12\omega^Bq. $

At

$\displaystyle q=1, \qquad \omega^B=\Omega\mathbf k, $

we obtain

$\displaystyle \dot q(0) = -\frac{\Omega}{2}\mathbf k. $

Solution 28: body resolved component equations

Let

$\displaystyle q=q_w+q_x\mathbf i+q_y\mathbf j+q_z\mathbf k $

and

$\displaystyle \omega^B = \omega_x\mathbf i+ \omega_y\mathbf j+ \omega_z\mathbf k. $

Expanding

$\displaystyle -\frac12\omega^Bq $

gives

$\displaystyle \dot q_w = \frac12 (\omega_xq_x+\omega_yq_y+\omega_zq_z), $

$\displaystyle \dot q_x = \frac12 (-\omega_xq_w+\omega_zq_y-\omega_yq_z), $

$\displaystyle \dot q_y = \frac12 (-\omega_yq_w-\omega_zq_x+\omega_xq_z), $

$\displaystyle \dot q_z = \frac12 (-\omega_zq_w+\omega_yq_x-\omega_xq_y). $

Solution 29: norm preservation

Differentiate

$\displaystyle q^*q=1. $

From

$\displaystyle \dot q = -\frac12\omega^Bq, $

we have

$\displaystyle \dot q^* = \frac12q^*\omega^B, $

because $\omega^B$ is pure.

Therefore

\begin{equation*} \begin{aligned} \frac{d}{dt}(q^*q) &= \dot q^*q+q^*\dot q\ &= \frac12q^*\omega^Bq -\frac12q^*\omega^Bq\ &= 0. \end{aligned}\end{equation*}

Hence unit norm is preserved exactly in continuous time.

Solution 30: exact constant rate propagation

The rate magnitude is

$\displaystyle \Omega = \sqrt{1^2+2^2+2^2} = 3\ \mathrm{rad/s}. $

The unit axis is

$\displaystyle \widehat{\boldsymbol\omega} = \frac13 \begin{bmatrix} 1\\ 2\\ 2 \end{bmatrix}. $

At $t=0.2$ s,

$\displaystyle \theta = \Omega t = 0.6\ \mathrm{rad}. $

Therefore

$\displaystyle q(t) = \cos0.3 - \frac13 (\mathbf i+2\mathbf j+2\mathbf k) \sin0.3. $

Numerically,

$\displaystyle q \approx \begin{bmatrix} 0.955336489\ -0.098506736\ -0.197013471\ -0.197013471 \end{bmatrix}. $

Solution 31: recover angular velocity

Start with

$\displaystyle \dot q = -\frac12\omega^Bq. $

Right multiply by $q^*$:

$\displaystyle \dot qq^* = -\frac12\omega^Bqq^* = -\frac12\omega^B. $

Thus

$\displaystyle \omega^B = -2\dot qq^*. $

Solution 32: body versus reference resolved rate

Given

$\displaystyle \omega^B = q\omega^Iq^*, $

we have

$\displaystyle \omega^Bq = q\omega^Iq^*q = q\omega^I. $

Therefore

$\displaystyle -\frac12\omega^Bq = -\frac12q\omega^I. $

The two equations describe the same physical angular velocity resolved in different frames.

Solution 33: forward Euler norm drift

At the identity,

$\displaystyle \dot q = -\frac12(0.5\mathbf k) = -0.25\mathbf k. $

For $\Delta t=0.1$ s,

$\displaystyle q_{k+1}^{E} = 1-0.025\mathbf k. $

The norm is

$\displaystyle \sqrt{1+0.025^2} = \sqrt{1.000625} \approx 1.000312451. $

The result is not exactly unit because the Euler step follows a tangent line rather than the unit quaternion three sphere.

Solution 34: DCM kinematics

For a physical vector fixed in inertial space,

$\displaystyle {}^{B}\mathbf v = {}^{B}C_I{}^{I}\mathbf v. $

A rotating frame observes

$\displaystyle {}^{B}\dot{\mathbf v} = -\omega^B\times{}^{B}\mathbf v. $

Thus

$\displaystyle {}^{B}\dot{\mathbf v} = -[\omega^B]_\times {}^{B}C_I {}^{I}\mathbf v. $

Since ${}^{I}\mathbf v$ is arbitrary,

$\displaystyle {}^{B}\dot C_I = -[\omega^B]_\times {}^{B}C_I. $

Solution 35: left and right errors

For a left error,

$\displaystyle q_d = \delta q_Lq. $

Right multiply by $q^*$:

$\displaystyle \delta q_L = q_dq^*. $

For a right error,

$\displaystyle q_d = q\delta q_R. $

Left multiply by $q^*$:

$\displaystyle \delta q_R = q^*q_d. $

Thus

$\displaystyle q_d = \delta q_Lq = q\delta q_R. $

Solution 36: same axis attitude error

The actual attitude is

$\displaystyle q = \cos5^\circ-\mathbf k\sin5^\circ. $

The desired attitude is

$\displaystyle q_d = \cos12.5^\circ-\mathbf k\sin12.5^\circ. $

Therefore

$\displaystyle \delta q_L = q_dq^* = \cos7.5^\circ-\mathbf k\sin7.5^\circ. $

This represents a positive frame yaw error of

$\displaystyle 15^\circ $

about $+\widehat{\mathbf z}$.

Because the rotations share the same axis, the left and right errors coincide.

Solution 37: small passive attitude error

For the passive small error convention,

$\displaystyle \delta\boldsymbol\theta \approx -2\delta\mathbf q_v. $

Therefore

$\displaystyle \delta\boldsymbol\theta \approx -2 \begin{bmatrix} 0.005\ -0.01... ...bmatrix}= \begin{bmatrix} -0.010\ 0.020\ -0.040 \end{bmatrix}\mathrm{rad}. $

Solution 38: transport right error to left error

Starting from

$\displaystyle \delta q_R=q^*q_d, $

multiply by $q$ on the left and $q^*$ on the right:

$\displaystyle q\delta q_Rq^* = qq^*q_dq^* = q_dq^* = \delta q_L. $

For small passive errors,

$\displaystyle \delta q_R \approx 1-\frac12\delta\boldsymbol\theta_R. $

Then

$\displaystyle \delta q_L \approx 1 - \frac12 q\delta\boldsymbol\theta_Rq^*. $

Since the quaternion sandwich transforms vector coordinates,

$\displaystyle \delta\boldsymbol\theta_L = C(q) \delta\boldsymbol\theta_R. $

Solution 39: principal sign choice

The scalar component is negative, so multiply the whole quaternion by $-1$:

$\displaystyle \delta q_p = \begin{bmatrix} 0.99904822\ 0\ 0\ -0.04361939 \end{bmatrix}. $

The scalar is approximately

$\displaystyle \cos2.5^\circ, $

so the full angle is

$\displaystyle 5^\circ. $

The passive vector part is along $-\mathbf k$, so the physical positive frame axis is $+\widehat{\mathbf z}$.

Thus the principal physical error is positive $5^\circ$ about $+z$.

Solution 40: bias corrected IMU update

The corrected rate is

$\displaystyle \widehat{\boldsymbol\omega}^B = \boldsymbol\omega_m^B - \widehat{\mathbf b}_g = \begin{bmatrix} 0\\ 0\\ 0.50 \end{bmatrix}\mathrm{rad/s}. $

The delta angle is

$\displaystyle \Delta\boldsymbol\theta^B = \widehat{\boldsymbol\omega}^B\Delta t = \begin{bmatrix} 0\\ 0\\ 0.05 \end{bmatrix}\mathrm{rad}. $

The exact passive increment is

$\displaystyle \delta q_B = \cos0.025 - \mathbf k\sin0.025. $

Numerically,

$\displaystyle \delta q_B \approx \begin{bmatrix} 0.999687516\ 0\ 0\ -0.024997396 \end{bmatrix}. $

Since $q_k=1$,

$\displaystyle q_{k+1} = \delta q_Bq_k = \delta q_B. $

Solution 41: body increment multiplication side

At sample $k$,

$\displaystyle q_k = {}^{B_k}q_I $

maps

$\displaystyle I\rightarrow B_k. $

The measured body increment is

$\displaystyle \delta q_B = {}^{B_{k+1}}q_{B_k}, $

which maps

$\displaystyle B_k\rightarrow B_{k+1}. $

The frame chain is therefore

$\displaystyle I \rightarrow B_k \rightarrow B_{k+1}. $

Thus

$\displaystyle {}^{B_{k+1}}q_I = {}^{B_{k+1}}q_{B_k} {}^{B_k}q_I, $

or

$\displaystyle q_{k+1} = \delta q_Bq_k. $

Solution 42: two small increments and coning

For small passive increments,

$\displaystyle \delta q_1 \approx 1-\frac12\Delta\boldsymbol\theta_1 $

and

$\displaystyle \delta q_2 \approx 1-\frac12\Delta\boldsymbol\theta_2. $

Chronological body increments compose as

$\displaystyle \delta q_{21} = \delta q_2\delta q_1. $

Expanding through second order,

$\displaystyle \delta q_{21} \approx 1 - \frac12 (\Delta\boldsymbol\theta_1+\Del... ...symbol\theta_2) + \frac14 \Delta\boldsymbol\theta_2 \Delta\boldsymbol\theta_1. $

The vector part of the last product is

$\displaystyle \frac14 \Delta\boldsymbol\theta_2 \times \Delta\boldsymbol\theta_1 = -\frac14 \Delta\boldsymbol\theta_1 \times \Delta\boldsymbol\theta_2. $

Matching

$\displaystyle 1-\frac12 \Delta\boldsymbol\theta_{\mathrm{eq}} $

gives

$\displaystyle \Delta\boldsymbol\theta_{\mathrm{eq}} \approx \Delta\boldsymbol\t... ...\theta_2 + \frac12 \Delta\boldsymbol\theta_1 \times \Delta\boldsymbol\theta_2. $

Solution 43: quaternion sign continuity

If

$\displaystyle q_{k+1}^Tq_k<0, $

replace

$\displaystyle q_{k+1} \leftarrow -q_{k+1}. $

The new quaternion represents exactly the same physical attitude because $q$ and $-q$ are equivalent.

The operation merely chooses the representative nearest the previous sample.

Solution 44: specific force transformation

The attitude quaternion

$\displaystyle q={}^Bq_I $

maps inertial coordinates into body coordinates.

Therefore the inverse DCM maps body specific force back into inertial coordinates:

$\displaystyle {}^{I}\mathbf f = {}^{I}C_B {}^{B}\mathbf f = C(q)^T {}^{B}\mathbf f. $

The equivalent quaternion expression is

$\displaystyle {}^{I}f = q^* {}^{B}f q. $

Solution 45: capstone convention audit

The legacy routine uses

$\displaystyle q_{k+1} = q_k \exp \left( +\frac12 \Delta\boldsymbol\theta^B \right). $

Relative to the PhysicsLibrary state $q={}^Bq_I$, two inconsistencies are present.

First, a positive body frame increment must have a negative quaternion vector sign:

$\displaystyle \delta q_B = \exp \left( -\frac12 \Delta\boldsymbol\theta^B \right). $

Second, a body resolved increment must left multiply the passive inertial to body state.

Therefore the corrected update is

$\displaystyle q_{k+1} = \exp \left( -\frac12 \Delta\boldsymbol\theta^B \right) q_k. $

Suggested grading progression

The problem set may be used in four passes:

  1. Exercises 1–8 for algebra and convention fluency;
  2. Exercises 9–26 for finite attitude representation and conversion;
  3. Exercises 27–39 for dynamics, estimation, and attitude error;
  4. Exercises 40–45 for sampled IMU propagation and implementation auditing.

A student who can solve the final convention audit without relying on a memorized active quaternion formula has internalized the central PhysicsLibrary convention.

Sources and exercise provenance

The exercises and worked solutions in this article are newly written or rewritten for the PhysicsLibrary passive quaternion series.

Hamilton provides the foundational algebra. Sommer and coauthors provide a modern analysis of quaternion convention management. Henderson provides an engineering reference for quaternion, matrix, and Euler conversion. Markley and Crassidis provide spacecraft attitude and error quaternion context. Solà and Savage provide useful treatments of quaternion kinematics, error states, and IMU propagation.

Bibliography

1
W. R. Hamilton, Elements of Quaternions, 2nd ed., edited by C. J. Joly, Longmans, Green, and Co., 1899. Public domain historical source. Internet Archive scan https://archive.org/details/elementsofquater01hamiuoft
2
H. Sommer, I. Gilitschenski, M. Bloesch, S. Weiss, R. Siegwart, and J. Nieto, “Why and How to Avoid the Flipped Quaternion Multiplication,” Aerospace, vol. 5, no. 3, article 72, 2018. Published under CC BY 4.0. Publisher article https://www.mdpi.com/2226-4310/5/3/72
3
D. M. Henderson, Euler Angles, Quaternions, and Transformation Matrices: Working Relationships, JSC-12960, NASA Johnson Space Center, 1977. NASA Technical Reports Server search https://ntrs.nasa.gov/search?q=JSC-12960
4
F. L. Markley and J. L. Crassidis, Fundamentals of Spacecraft Attitude Determination and Control, Springer, 2014. Publisher book page https://link.springer.com/book/10.1007/978-1-4939-0802-8
5
J. Solà, “Quaternion Kinematics for the Error State Kalman Filter,” arXiv:1711.02508, 2017. arXiv preprint https://arxiv.org/abs/1711.02508
6
P. G. Savage, “Strapdown Inertial Navigation Integration Algorithm Design Part 1: Attitude Algorithms,” Journal of Guidance, Control, and Dynamics, vol. 21, no. 1, pp. 19–28, 1998. DOI record https://doi.org/10.2514/2.4228

License

Unless otherwise noted, this PhysicsLibrary entry is intended for release under the Creative Commons Attribution ShareAlike 4.0 International license.



"quaternion exercises for physics and engineering" is owned by bloftin.
(view preamble)
View style:
See Also: quaternion series overview and article guide, Notation Quaternions for Physics and Engineering: Orientation, quaternion definition and basic algebra, example of quaternion definition and basic algebra, quaternion product, example of quaternion product, quaternion conjugate, example of quaternion conjugate, quaternion norm, example of quaternion norm, quaternion inverse, example of quaternion inverse

Keywords:  quaternion, rotation, attitude, direction cosine matrix, Euler angles, angular velocity, IMU, exercises, worked solutions

This object's parent.

Cross-references: magnitude, trace, commute, conjugation, cross product, force, operation, relation, error quaternion, kinematic, velocity, Euler Angles, composition, matrix, direction cosine matrix, formula, square, representation, vector, norm, identity, quaternion product, scalar, quaternion
There is 1 reference to this object.

This is version 2 of quaternion exercises for physics and engineering, born on 2026-08-24, modified 2026-08-28.
Object id is 1112, canonical name is QuaternionExercisesForPhysicsAndEngineering.
Accessed 85 times total.

Classification:
Physics Classification02.40.Yy (Geometric mechanics )
 02.10.Hh (Rings and algebras)
 45.40.-f (Dynamics and kinematics of rigid bodies)
 06.30.Gv (Velocity, acceleration, and rotation)
Pending Errata and Addenda
None.
Discussion
Style: Expand: Order:

No messages.

Interact
rate | post | correct | update request | add example | add (any)