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] example of quaternion kinematics and angular velocity (Example)

Quaternion kinematics and angular velocity: examples, exercises, and solutions

This companion article belongs to the PhysicsLibrary entry quaternion kinematics and angular velocity. All exercises are stated first. Complete solutions appear only after the exercise section so that the article is self study friendly.

Convention declaration

We use the attitude quaternion $q={}^Iq_B$, Hamilton multiplication, scalar-first display notation, and

$\displaystyle \dot q=\frac12q\omega^{B}$ (1)
for body resolved angular velocity, while
$\displaystyle \dot q=\frac12\omega^{I}q$ (2)
for inertial resolved angular velocity.

Exercises

Exercise 1

Starting from a short time body frame rotation increment, derive
$\displaystyle \dot q=\frac12q\omega^{B}.$ (3)

Exercise 2

Starting from an inertial frame rotation increment, derive
$\displaystyle \dot q=\frac12\omega^{I}q.$ (4)

Exercise 3

Show that the body resolved and inertial resolved equations are equivalent if
$\displaystyle \omega^{I}=q\omega^{B}q^*.$ (5)

Exercise 4

Let
$\displaystyle q=\frac{1+\mathbf k}{\sqrt2}$ (6)
and let the body resolved angular velocity be
$\displaystyle \boldsymbol\omega^{B}= \begin{bmatrix}0.2\\ 0\\ 0\end{bmatrix}\ \mathrm{rad/s}.$ (7)
Compute $\dot q$.

Exercise 5

For the same attitude in Exercise 4, find the inertial resolved angular velocity $\boldsymbol\omega^{I}$ and verify that the inertial rate equation gives the same $\dot q$.

Exercise 6

Derive the scalar and vector equations
$\displaystyle \dot q_w=-\frac12\mathbf q\cdot\boldsymbol\omega^{B},$ (8)
$\displaystyle \dot{\mathbf q}=\frac12\left(q_w\boldsymbol\omega^{B}+\mathbf q\times\boldsymbol\omega^{B}\right).$ (9)

Exercise 7

Derive the $4\times4$ right multiplication rate matrix $\Omega_R(\boldsymbol\omega)$ for scalar-first ordering.

Exercise 8

Derive the $4\times4$ left multiplication rate matrix $\Omega_L(\boldsymbol\omega)$ for scalar-first ordering.

Exercise 9

Prove that the continuous quaternion kinematic equation preserves the norm of a unit quaternion.

Exercise 10

Starting from $q(0)=1$, let
$\displaystyle \boldsymbol\omega^{B}= \begin{bmatrix}0\\ 0\\ 0.4\end{bmatrix}\ \mathrm{rad/s}$ (10)
be constant. Find $q(t)$ exactly.

Exercise 11

For the angular rate in Exercise 10, compute the exact quaternion after $\Delta t=0.5\ \mathrm{s}$.

Exercise 12

Use one forward Euler step with $\Delta t=0.5\ \mathrm{s}$ for Exercise 10. Compute the norm of the unnormalized result and compare it with the exact quaternion.

Exercise 13

A body mounted gyro reports
$\displaystyle \boldsymbol\omega^{B}= \begin{bmatrix}0.01\\ -0.02\\ 0.03\end{bmatrix}\ \mathrm{rad/s}$ (11)
for $\Delta t=0.01\ \mathrm{s}$. Form the first order incremental quaternion.

Exercise 14

Explain why replacing an attitude trajectory $q(t)$ by $-q(t)$ requires replacing $\dot q(t)$ by $-\dot q(t)$ but does not change the physical motion.

Exercise 15

A program stores quaternions scalar last and uses the body rate matrix written for scalar-first ordering without permuting the state. Explain the resulting bug and how to correct it.

Exercise 16

A programmer uses
$\displaystyle \dot q=\frac12\omega^{B}q$ (12)
for a quaternion $q={}^Iq_B$ driven by body resolved gyro measurements. What is wrong, and what symptom would you expect for rotations not aligned with a principal coordinate axis?

Solutions

Solution 1

Over $dt$, the body frame incremental rotation is
$\displaystyle \delta q_B=1+\frac12\omega^{B}dt+O(dt^2).$ (13)
Since it is resolved about the current body axes, it composes on the right:
$\displaystyle q(t+dt)=q(t)\delta q_B.$ (14)
Thus
$\displaystyle \frac{q(t+dt)-q(t)}{dt}=\frac12q(t)\omega^{B}+O(dt),$ (15)
and taking $dt\to0$ gives
$\displaystyle \boxed{\dot q=\frac12q\omega^{B}.}$ (16)

Solution 2

For an inertial resolved increment,
$\displaystyle \delta q_I=1+\frac12\omega^{I}dt+O(dt^2),$ (17)
and the increment composes on the left:
$\displaystyle q(t+dt)=\delta q_Iq(t).$ (18)
Therefore
$\displaystyle \boxed{\dot q=\frac12\omega^{I}q.}$ (19)

Solution 3

Using
$\displaystyle \omega^{I}=q\omega^{B}q^*$ (20)
and $q^*q=1$,
$\displaystyle \omega^{I}q=q\omega^{B}q^*q=q\omega^{B}.$ (21)
Multiplying by $1/2$ proves that the two kinematic equations are identical.

Solution 4

Write
$\displaystyle q=\frac{1}{\sqrt2}+\frac{1}{\sqrt2}\mathbf k, \qquad \omega^{B}=0.2\mathbf i.$ (22)
Then
\begin{equation*}\begin{aligned} q\omega^{B} &=\left(\frac{1}{\sqrt2}+\frac{1}{\... ...{0.2}{\sqrt2}\mathbf i+\frac{0.2}{\sqrt2}\mathbf j, \end{aligned}\end{equation*}
because $\mathbf k\mathbf i=\mathbf j$. Hence
$\displaystyle \boxed{ \dot q=\frac{0.1}{\sqrt2}(\mathbf i+\mathbf j). }$ (24)

Solution 5

The attitude is a $+90^\circ$ rotation about $z$, so a body frame $+x$ vector is mapped into inertial $+y$. Therefore
$\displaystyle \boldsymbol\omega^{I}= \begin{bmatrix}0\\ 0.2\\ 0\end{bmatrix}\ \mathrm{rad/s}, \qquad \omega^{I}=0.2\mathbf j.$ (25)
Then
\begin{equation*}\begin{aligned} \omega^{I}q &=(0.2\mathbf j)\left(\frac{1}{\sqr... ...{0.2}{\sqrt2}\mathbf j+\frac{0.2}{\sqrt2}\mathbf i, \end{aligned}\end{equation*}
which gives exactly the same $\dot q$ as Exercise 4.

Solution 6

Using the scalar vector Hamilton product,
$\displaystyle (q_w,\mathbf q)(0,\boldsymbol\omega^{B}) =\left(-\mathbf q\cdot\b... ...ga^{B}, q_w\boldsymbol\omega^{B}+\mathbf q\times\boldsymbol\omega^{B}\right).$ (27)
Multiplying by $1/2$ gives the required scalar and vector equations.

Solution 7

Expanding $q\omega^{B}$ in scalar-first ordering gives
$\displaystyle \boxed{ \Omega_R(\boldsymbol\omega)= \begin{bmatrix} 0&-\omega_x&... ...\omega_y&-\omega_z&0&\omega_x\ \omega_z&\omega_y&-\omega_x&0 \end{bmatrix}. }$ (28)
Thus $\dot{\mathbf q}_4=(1/2)\Omega_R\mathbf q_4$.

Solution 8

Expanding $\omega^{I}q$ gives
$\displaystyle \boxed{ \Omega_L(\boldsymbol\omega)= \begin{bmatrix} 0&-\omega_x&... ...\omega_y&\omega_z&0&-\omega_x\ \omega_z&-\omega_y&\omega_x&0 \end{bmatrix}. }$ (29)
Thus $\dot{\mathbf q}_4=(1/2)\Omega_L\mathbf q_4$.

Solution 9

Both $\Omega_R$ and $\Omega_L$ are skew symmetric. Therefore
$\displaystyle \frac{d}{dt}(\mathbf q_4^T\mathbf q_4) =2\mathbf q_4^T\dot{\mathbf q}_4 =\mathbf q_4^T\Omega\mathbf q_4=0.$ (30)
Hence the exact continuous equation preserves $\Vert q\Vert$.

Solution 10

The angular speed magnitude is $0.4\ \mathrm{rad/s}$ and the axis is $\mathbf k$. Therefore
$\displaystyle \boxed{ q(t)=\cos(0.2t)+\mathbf k\sin(0.2t). }$ (31)
The physical rotation angle is $0.4t$ radians.

Solution 11

At $t=0.5\ \mathrm{s}$,
$\displaystyle \frac{\omega t}{2}=\frac{0.4(0.5)}{2}=0.1.$ (32)
Thus
$\displaystyle q(0.5)=\cos(0.1)+\mathbf k\sin(0.1)$ (33)
or numerically
$\displaystyle \boxed{q(0.5)\approx0.995004+0.0998334\mathbf k.}$ (34)

Solution 12

At $q_0=1$,
$\displaystyle \dot q_0=\frac12(0.4\mathbf k)=0.2\mathbf k.$ (35)
A forward Euler step gives
$\displaystyle q_1^{E}=1+(0.5)(0.2\mathbf k)=1+0.1\mathbf k.$ (36)
Its norm is
$\displaystyle \Vert q_1^{E}\Vert=\sqrt{1+0.1^2}=\sqrt{1.01}\approx1.00499.$ (37)
The exact quaternion from Exercise 11 has norm exactly one.

Solution 13

The first order increment is
$\displaystyle \delta q\approx1+\frac12\omega^{B}\Delta t.$ (38)
Therefore
$\displaystyle \boxed{ \delta q\approx 1+0.00005\mathbf i-0.00010\mathbf j+0.00015\mathbf k. }$ (39)

Solution 14

If $q(t)$ satisfies the kinematic equation, multiplying the entire trajectory by $-1$ gives the same physical orientation because $q$ and $-q$ represent the same rotation. Differentiating $-q(t)$ gives $-\dot q(t)$. The kinematic equation is linear in $q$, so the sign reversed pair remains a valid solution describing the same physical motion.

Solution 15

The matrix sign pattern assumes the state order $[q_w,q_x,q_y,q_z]^T$. A scalar-last array uses a different ordering, so direct multiplication associates the wrong coefficients with the wrong state components. The state and matrix must be permuted consistently, or the quaternion must be converted to scalar-first ordering before applying the formula.

Solution 16

For $q={}^Iq_B$ and body resolved gyro measurements, the correct equation is
$\displaystyle \dot q=\frac12q\omega^{B}.$ (40)
Using $\omega^{B}q$ treats the numerical components as though they were resolved in the inertial frame. For single axis rotations aligned with an axis that commutes with the current quaternion, the error can be hidden. For general three-dimensional motion, the attitude will propagate with incorrect coupling and sign behavior because quaternion multiplication is not commutative.

License

This article is an original synthesis prepared for PhysicsLibrary and intended for release under CC BY-SA 4.0.



"example of quaternion kinematics and angular velocity" is owned by bloftin.
(view preamble)
View style:
Keywords:  quaternion, angular velocity, quaternion kinematics, attitude propagation, gyroscope, exercises, worked solutions

This object's parent.

Cross-references: quaternion multiplication, commutes, formula, magnitude, speed, program, motion, norm, kinematic, matrix, vector, scalar, velocity, quaternion, section, quaternion kinematics and angular velocity

This is version 1 of example of quaternion kinematics and angular velocity, born on 2026-08-24.
Object id is 1106, canonical name is ExampleOfQuaternionKinematicsAndAngularVelocity.
Accessed 4 times total.

Classification:
Physics Classification45.40.-f (Dynamics and kinematics of rigid bodies)
 02.40.Yy (Geometric mechanics )
 02.10.Hh (Rings and algebras)
Pending Errata and Addenda
None.
Discussion
Style: Expand: Order:

No messages.

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