<?xml version="1.0" encoding="UTF-8"?>

<record version="1" id="1106">
 <title>example of quaternion kinematics and angular velocity</title>
 <name>ExampleOfQuaternionKinematicsAndAngularVelocity</name>
 <created>2026-08-24 02:19:48</created>
 <modified>2026-08-24 02:19:48</modified>
 <type>Example</type>
<parent id="1105">quaternion kinematics and angular velocity</parent>
 <creator id="1" name="bloftin"/>
 <modifier id="1" name="bloftin"/>
 <comment>convert to passive rotation convention</comment>
 <author id="1" name="bloftin"/>
 <classification>
	<category scheme="pacs" code="45.40.-f"/>
	<category scheme="pacs" code="02.40.Yy"/>
	<category scheme="pacs" code="02.10.Hh"/>
 </classification>
 <keywords>
	<term>quaternion</term>
	<term>angular velocity</term>
	<term>quaternion kinematics</term>
	<term>attitude propagation</term>
	<term>gyroscope</term>
	<term>exercises</term>
	<term>worked solutions</term>
 </keywords>
 <preamble>% this is the default PhysicsLibrary preamble.  as your knowledge
% of TeX increases, you will probably want to edit this, but
% it should be fine as is for beginners.

% almost certainly you want these
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsfonts}

% used for TeXing text within eps files
%\usepackage{psfrag}
% need this for including graphics (\includegraphics).
% If you use \includegraphics{figure} with no file extension, PhysicsLibrary
% will prefer figure.png before falling back to figure.eps.
\usepackage{graphicx}
\DeclareGraphicsExtensions{.png,.jpg,.jpeg,.pdf,.eps}
% for neatly defining theorems and propositions
%\usepackage{amsthm}
% making logically defined graphics
%\usepackage{xypic}

% there are many more packages, add them here as you need them

% define commands here</preamble>
 <content>\section*{Quaternion kinematics and angular velocity: examples, exercises, and solutions}

This companion article belongs to the PhysicsLibrary entry
\emph{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.

\section{Convention declaration}

We use the attitude quaternion $q={}^Iq_B$, Hamilton multiplication,
scalar-first display notation, and
\begin{equation}
\dot q=\frac12q\omega^{B}
\end{equation}
for body resolved angular velocity, while
\begin{equation}
\dot q=\frac12\omega^{I}q
\end{equation}
for inertial resolved angular velocity.

\section{Exercises}

\subsection*{Exercise 1}
Starting from a short time body frame rotation increment, derive
\begin{equation}
\dot q=\frac12q\omega^{B}.
\end{equation}

\subsection*{Exercise 2}
Starting from an inertial frame rotation increment, derive
\begin{equation}
\dot q=\frac12\omega^{I}q.
\end{equation}

\subsection*{Exercise 3}
Show that the body resolved and inertial resolved equations are equivalent if
\begin{equation}
\omega^{I}=q\omega^{B}q^*.
\end{equation}

\subsection*{Exercise 4}
Let
\begin{equation}
q=\frac{1+\mathbf k}{\sqrt2}
\end{equation}
and let the body resolved angular velocity be
\begin{equation}
\boldsymbol\omega^{B}=
\begin{bmatrix}0.2\\0\\0\end{bmatrix}\ \mathrm{rad/s}.
\end{equation}
Compute $\dot q$.

\subsection*{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$.

\subsection*{Exercise 6}
Derive the scalar and vector equations
\begin{equation}
\dot q_w=-\frac12\mathbf q\cdot\boldsymbol\omega^{B},
\end{equation}
\begin{equation}
\dot{\mathbf q}=\frac12\left(q_w\boldsymbol\omega^{B}+\mathbf q\times\boldsymbol\omega^{B}\right).
\end{equation}

\subsection*{Exercise 7}
Derive the $4\times4$ right multiplication rate matrix
$\Omega_R(\boldsymbol\omega)$ for scalar-first ordering.

\subsection*{Exercise 8}
Derive the $4\times4$ left multiplication rate matrix
$\Omega_L(\boldsymbol\omega)$ for scalar-first ordering.

\subsection*{Exercise 9}
Prove that the continuous quaternion kinematic equation preserves the norm of a
unit quaternion.

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

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

\subsection*{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.

\subsection*{Exercise 13}
A body mounted gyro reports
\begin{equation}
\boldsymbol\omega^{B}=
\begin{bmatrix}0.01\\-0.02\\0.03\end{bmatrix}\ \mathrm{rad/s}
\end{equation}
for $\Delta t=0.01\ \mathrm{s}$.  Form the first order incremental quaternion.

\subsection*{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.

\subsection*{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.

\subsection*{Exercise 16}
A programmer uses
\begin{equation}
\dot q=\frac12\omega^{B}q
\end{equation}
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?

\section{Solutions}

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

\subsection*{Solution 2}
For an inertial resolved increment,
\begin{equation}
\delta q_I=1+\frac12\omega^{I}dt+O(dt^2),
\end{equation}
and the increment composes on the left:
\begin{equation}
q(t+dt)=\delta q_Iq(t).
\end{equation}
Therefore
\begin{equation}
\boxed{\dot q=\frac12\omega^{I}q.}
\end{equation}

\subsection*{Solution 3}
Using
\begin{equation}
\omega^{I}=q\omega^{B}q^*
\end{equation}
and $q^*q=1$,
\begin{equation}
\omega^{I}q=q\omega^{B}q^*q=q\omega^{B}.
\end{equation}
Multiplying by $1/2$ proves that the two kinematic equations are identical.

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

\subsection*{Solution 5}
The attitude is a $+90^\circ$ rotation about $z$, so a body frame $+x$ vector is
mapped into inertial $+y$.  Therefore
\begin{equation}
\boldsymbol\omega^{I}=
\begin{bmatrix}0\\0.2\\0\end{bmatrix}\ \mathrm{rad/s},
\qquad
\omega^{I}=0.2\mathbf j.
\end{equation}
Then
\begin{equation}
\begin{aligned}
\omega^{I}q
&amp;=(0.2\mathbf j)\left(\frac{1}{\sqrt2}+\frac{1}{\sqrt2}\mathbf k\right)\\
&amp;=\frac{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.

\subsection*{Solution 6}
Using the scalar vector Hamilton product,
\begin{equation}
(q_w,\mathbf q)(0,\boldsymbol\omega^{B})
=\left(-\mathbf q\cdot\boldsymbol\omega^{B},\
q_w\boldsymbol\omega^{B}+\mathbf q\times\boldsymbol\omega^{B}\right).
\end{equation}
Multiplying by $1/2$ gives the required scalar and vector equations.

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

\subsection*{Solution 8}
Expanding $\omega^{I}q$ gives
\begin{equation}
\boxed{
\Omega_L(\boldsymbol\omega)=
\begin{bmatrix}
0&amp;-\omega_x&amp;-\omega_y&amp;-\omega_z\\
\omega_x&amp;0&amp;-\omega_z&amp;\omega_y\\
\omega_y&amp;\omega_z&amp;0&amp;-\omega_x\\
\omega_z&amp;-\omega_y&amp;\omega_x&amp;0
\end{bmatrix}.
}
\end{equation}
Thus $\dot{\mathbf q}_4=(1/2)\Omega_L\mathbf q_4$.

\subsection*{Solution 9}
Both $\Omega_R$ and $\Omega_L$ are skew symmetric.  Therefore
\begin{equation}
\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.
\end{equation}
Hence the exact continuous equation preserves $\|q\|$.

\subsection*{Solution 10}
The angular speed magnitude is $0.4\ \mathrm{rad/s}$ and the axis is
$\mathbf k$.  Therefore
\begin{equation}
\boxed{
q(t)=\cos(0.2t)+\mathbf k\sin(0.2t).
}
\end{equation}
The physical rotation angle is $0.4t$ radians.

\subsection*{Solution 11}
At $t=0.5\ \mathrm{s}$,
\begin{equation}
\frac{\omega t}{2}=\frac{0.4(0.5)}{2}=0.1.
\end{equation}
Thus
\begin{equation}
q(0.5)=\cos(0.1)+\mathbf k\sin(0.1)
\end{equation}
or numerically
\begin{equation}
\boxed{q(0.5)\approx0.995004+0.0998334\mathbf k.}
\end{equation}

\subsection*{Solution 12}
At $q_0=1$,
\begin{equation}
\dot q_0=\frac12(0.4\mathbf k)=0.2\mathbf k.
\end{equation}
A forward Euler step gives
\begin{equation}
q_1^{E}=1+(0.5)(0.2\mathbf k)=1+0.1\mathbf k.
\end{equation}
Its norm is
\begin{equation}
\|q_1^{E}\|=\sqrt{1+0.1^2}=\sqrt{1.01}\approx1.00499.
\end{equation}
The exact quaternion from Exercise 11 has norm exactly one.

\subsection*{Solution 13}
The first order increment is
\begin{equation}
\delta q\approx1+\frac12\omega^{B}\Delta t.
\end{equation}
Therefore
\begin{equation}
\boxed{
\delta q\approx
1+0.00005\mathbf i-0.00010\mathbf j+0.00015\mathbf k.
}
\end{equation}

\subsection*{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.

\subsection*{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.

\subsection*{Solution 16}
For $q={}^Iq_B$ and body resolved gyro measurements, the correct equation is
\begin{equation}
\dot q=\frac12q\omega^{B}.
\end{equation}
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.

\section*{License}

This article is an original synthesis prepared for PhysicsLibrary and intended
for release under CC BY-SA 4.0.</content>
</record>
