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

<record version="1" id="1100">
 <title>example of composition of rotations and quaternion order</title>
 <name>ExampleOfCompositionOfRotationsAndQuaternionOrder</name>
 <created>2026-08-23 23:15:13</created>
 <modified>2026-08-23 23:15:13</modified>
 <type>Example</type>
<parent id="1099">composition of rotations and quaternion order</parent>
 <creator id="1" name="bloftin"/>
 <modifier id="1" name="bloftin"/>
 <comment>converted to passive rotation convention</comment>
 <author id="1" name="bloftin"/>
 <classification>
	<category scheme="pacs" code="02.40.Yy"/>
	<category scheme="pacs" code="02.10.Hh"/>
	<category scheme="pacs" code="45.40.-f"/>
 </classification>
 <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)
%\usepackage{graphicx}
% 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*{Composition of Rotations and Quaternion Order: Examples, Exercises, and Solutions}

This companion article belongs to the PhysicsLibrary entry
\emph{Composition of Rotations and Quaternion Order}.  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 right-handed frames, Hamilton multiplication, scalar-first display
notation, and the active rotation rule
\begin{equation}
\mathbf v'=q\mathbf v q^*
\end{equation}
for unit quaternions.  If $q_1$ acts first and $q_2$ acts second, then the net
quaternion is
\begin{equation}
q_{\mathrm{net}}=q_2q_1.
\end{equation}

\section{Exercises}

\subsection*{Exercise 1}
Show directly from the active rotation formula that if $q_1$ acts first and
$q_2$ acts second, then the net quaternion is $q_2q_1$.

\subsection*{Exercise 2}
Let
\begin{equation}
q_z=\frac{1+\mathbf k}{\sqrt2}
\end{equation}
represent a $+90^\circ$ rotation about the $z$ axis, and let
\begin{equation}
q_x=\frac{1+\mathbf i}{\sqrt2}
\end{equation}
represent a $+90^\circ$ rotation about the $x$ axis.  Starting from
$\mathbf v=\mathbf j$, compute the final vector when the order is
first $q_z$ then $q_x$.

\subsection*{Exercise 3}
Repeat Exercise 2 but reverse the order: first $q_x$ then $q_z$.  Compare the
result with Exercise 2.

\subsection*{Exercise 4}
Using
\begin{equation}
q_x=\frac{1+\mathbf i}{\sqrt2},
\qquad
q_y=\frac{1+\mathbf j}{\sqrt2},
\end{equation}
start from $\mathbf v=\mathbf k$ and verify that first $q_x$ then $q_y$ gives
$-\mathbf j$, while first $q_y$ then $q_x$ gives $\mathbf i$.

\subsection*{Exercise 5}
Let
\begin{equation}
q_1=\cos\frac{\alpha}{2}+\widehat{\mathbf u}\sin\frac{\alpha}{2},
\qquad
q_2=\cos\frac{\beta}{2}+\widehat{\mathbf u}\sin\frac{\beta}{2}
\end{equation}
be rotations about the same unit axis $\widehat{\mathbf u}$.  Show that
\begin{equation}
q_2q_1=\cos\frac{\alpha+\beta}{2}+\widehat{\mathbf u}\sin\frac{\alpha+\beta}{2}.
\end{equation}

\subsection*{Exercise 6}
Suppose $q$ is unit.  Show that applying $q$ and then $q^*$ gives the identity
rotation.

\subsection*{Exercise 7}
A software library stores quaternions as $[q_x,q_y,q_z,q_w]^T$.  Does that fact
alone change the composition rule for active rotations?  Explain briefly.

\subsection*{Exercise 8}
Write the frame-chain rule for ${}^{N}q_A$ and ${}^{A}q_B$, and derive
${}^{N}q_B$.

\subsection*{Exercise 9}
Explain the difference between an intrinsic $z$-then-$x$ sequence and an
extrinsic $z$-then-$x$ sequence.

\subsection*{Exercise 10}
Show that if $R(q)$ is the active rotation matrix associated with $q$, then
\begin{equation}
R(q_2q_1)=R(q_2)R(q_1).
\end{equation}

\subsection*{Exercise 11}
Let
\begin{equation}
q_1=\frac{1+\mathbf i}{\sqrt2},
\qquad
q_2=\frac{1+\mathbf j}{\sqrt2}.
\end{equation}
Compute the explicit quaternion products $q_2q_1$ and $q_1q_2$ and verify that
they differ.

\subsection*{Exercise 12}
Give a passive-rotation formula corresponding to the active sequence
``first $q_1$, then $q_2$''.

\subsection*{Exercise 13}
Why do small-angle rotations often appear to commute in first-order linearized
attitude-error models even though finite rotations do not commute exactly?

\subsection*{Exercise 14}
Let
\begin{equation}
q_1=\frac{1+\mathbf k}{\sqrt2},
\qquad
q_2=\frac{1-\mathbf k}{\sqrt2}.
\end{equation}
Find $q_2q_1$ and interpret the result physically.

\subsection*{Exercise 15}
A student says, ``Since multiplication is associative, the order of quaternion
rotations does not matter.''  Identify the mistake in this statement.

\section{Solutions}

\subsection*{Solution 1}
If $q_1$ acts first, then $\mathbf v_1=q_1\mathbf v q_1^*$.  If $q_2$ acts next,
then
\begin{equation}
\mathbf v_2=q_2\mathbf v_1 q_2^*=q_2(q_1\mathbf v q_1^*)q_2^*.
\end{equation}
By associativity,
\begin{equation}
\mathbf v_2=(q_2q_1)\mathbf v(q_1^*q_2^*).
\end{equation}
Since $(q_2q_1)^*=q_1^*q_2^*$,
\begin{equation}
\mathbf v_2=(q_2q_1)\mathbf v(q_2q_1)^*.
\end{equation}
Hence the net quaternion is $q_2q_1$.

\subsection*{Solution 2}
First rotate $\mathbf j$ about $z$ by $+90^\circ$:
\begin{equation}
q_z\mathbf j q_z^*=-\mathbf i.
\end{equation}
Then rotate $-\mathbf i$ about $x$ by $+90^\circ$.  A vector on the $x$ axis is
unchanged, so
\begin{equation}
q_x(-\mathbf i)q_x^*=-\mathbf i.
\end{equation}
Therefore the final vector is $-\mathbf i$.

\subsection*{Solution 3}
First rotate $\mathbf j$ about $x$ by $+90^\circ$:
\begin{equation}
q_x\mathbf j q_x^*=\mathbf k.
\end{equation}
Then rotate $\mathbf k$ about $z$ by $+90^\circ$.  A vector on the $z$ axis is
unchanged, so the final vector remains $\mathbf k$.  This differs from the
result of Exercise 2, so the order matters.

\subsection*{Solution 4}
Using the standard axis rotations,
\begin{equation}
q_x\mathbf k q_x^*=-\mathbf j.
\end{equation}
Rotating $-\mathbf j$ about $y$ leaves it unchanged, so first $q_x$ then $q_y$
gives $-\mathbf j$.  Also,
\begin{equation}
q_y\mathbf k q_y^*=\mathbf i,
\end{equation}
and rotating $\mathbf i$ about $x$ leaves it unchanged.  So first $q_y$ then
$q_x$ gives $\mathbf i$.

\subsection*{Solution 5}
Because both quaternions use the same axis $\widehat{\mathbf u}$,
\begin{equation}
\begin{aligned}
q_2q_1
&amp;=\left(\cos\frac{\beta}{2}+\widehat{\mathbf u}\sin\frac{\beta}{2}\right)
  \left(\cos\frac{\alpha}{2}+\widehat{\mathbf u}\sin\frac{\alpha}{2}\right)\\
&amp;=\cos\frac{\beta}{2}\cos\frac{\alpha}{2}
-\sin\frac{\beta}{2}\sin\frac{\alpha}{2}\\
&amp;\qquad
+\widehat{\mathbf u}\left(
\sin\frac{\beta}{2}\cos\frac{\alpha}{2}
+\cos\frac{\beta}{2}\sin\frac{\alpha}{2}
\right),
\end{aligned}
\end{equation}
where $\widehat{\mathbf u}^{\,2}=-1$.  The angle-addition formulas then give
\begin{equation}
q_2q_1=\cos\frac{\alpha+\beta}{2}+\widehat{\mathbf u}\sin\frac{\alpha+\beta}{2}.
\end{equation}

\subsection*{Solution 6}
The net quaternion is
\begin{equation}
q^*q=qq^*=1,
\end{equation}
so the second rotation exactly undoes the first.  Therefore the composition is
the identity rotation.

\subsection*{Solution 7}
No.  Scalar-last is only a storage convention.  The composition rule depends on
the algebra and the rotation interpretation, not on memory layout.  For active
rotations with Hamilton multiplication, if $q_1$ acts first and $q_2$ acts
second, the net quaternion is still $q_2q_1$.

\subsection*{Solution 8}
The frame-chain rule is
\begin{equation}
\boxed{{}^{N}q_B={}^{N}q_A{}^{A}q_B.}
\end{equation}
It is derived by substituting the map from $B$ to $A$ into the map from $A$ to
$N$ and regrouping, exactly as for successive active rotations.

\subsection*{Solution 9}
In an extrinsic $z$-then-$x$ sequence, both rotations are taken about axes fixed
in the reference frame.  In an intrinsic $z$-then-$x$ sequence, the second
rotation is about the body's current $x$ axis after the first rotation has
already occurred.  The axis labels can therefore refer to different physical
axes in the two descriptions.

\subsection*{Solution 10}
For any vector $\mathbf v$,
\begin{equation}
R(q_2q_1)\mathbf v=(q_2q_1)\mathbf v(q_2q_1)^*=q_2(q_1\mathbf v q_1^*)q_2^*=R(q_2)R(q_1)\mathbf v.
\end{equation}
Since this holds for every $\mathbf v$, the matrices are equal:
\begin{equation}
R(q_2q_1)=R(q_2)R(q_1).
\end{equation}

\subsection*{Solution 11}
Compute
\begin{equation}
\begin{aligned}
q_2q_1
&amp;=\frac{1}{2}(1+\mathbf j)(1+\mathbf i)\\
&amp;=\frac{1}{2}(1+\mathbf i+\mathbf j+\mathbf j\mathbf i)\\
&amp;=\frac{1}{2}(1+\mathbf i+\mathbf j-\mathbf k),
\end{aligned}
\end{equation}
because $\mathbf j\mathbf i=-\mathbf k$.  Similarly,
\begin{equation}
q_1q_2=\frac{1}{2}(1+\mathbf i+\mathbf j+\mathbf k).
\end{equation}
The products differ, so the corresponding rotations differ.

\subsection*{Solution 12}
The passive formula is obtained by using the inverse action.  If $q_1$ acts
first and $q_2$ acts second in the active sense, then the passive coordinate
change uses
\begin{equation}
\mathbf v_{\mathrm{passive}}=(q_2q_1)^*\mathbf v(q_2q_1)=q_1^*q_2^*\mathbf v q_2q_1.
\end{equation}

\subsection*{Solution 13}
In a first-order small-angle model, products of two small rotation increments
are second-order quantities and are neglected.  The noncommutativity is then
invisible at first order.  For finite rotations, those higher-order terms are
not negligible, so the order matters.

\subsection*{Solution 14}
Since $q_2=q_1^*$,
\begin{equation}
q_2q_1=q_1^*q_1=1.
\end{equation}
The net effect is no rotation.  The second quarter-turn exactly cancels the
first.

\subsection*{Solution 15}
Associativity means that one may regroup factors without changing their order,
for example $(q_2q_1)q_0=q_2(q_1q_0)$.  It does \emph{not} mean one may swap the
order of factors.  Commutativity would be the property $q_2q_1=q_1q_2$, and
that property fails in general for finite rotations.

\section*{License}

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