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

<record version="2" id="1099">
 <title>composition of rotations and quaternion order</title>
 <name>CompositionOfRotationsAndQuaternionOrder</name>
 <created>2026-08-23 23:11:21</created>
 <modified>2026-08-24 00:30:29</modified>
 <type>Definition</type>
 <creator id="1" name="bloftin"/>
 <modifier id="1" name="bloftin"/>
 <comment>converted to passive rotation convention and updated figure too for passive</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>
 <keywords>
	<term>quaternion</term>
	<term>composition of rotations</term>
	<term>rotation order</term>
	<term>quaternion product</term>
	<term>noncommutativity</term>
	<term>active rotation</term>
	<term>passive rotation</term>
	<term>intrinsic rotations</term>
	<term>extrinsic rotations</term>
	<term>frame chain</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)
\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}

A single unit quaternion represents one spatial rotation.  In applications,
however, one usually performs \emph{successive} rotations: a body is rotated by
one command, then by another; one frame is related to a second, then that frame
to a third; or one attitude update is followed by another.  The central
question is therefore not only how one quaternion rotates a vector, but also
how several quaternion rotations compose.

This entry derives the composition law for active rotations, explains why the
product order matters, connects quaternion chains to direction-cosine-matrix
chains, and clarifies the intrinsic and extrinsic language commonly used in
mechanics, robotics, and aerospace work.

\section{Convention declaration}

This article uses the PhysicsLibrary house convention:
\begin{enumerate}
\item right-handed orthonormal frames;
\item Hamilton multiplication, so $\mathbf i\mathbf j=\mathbf k$;
\item scalar-first display notation,
\begin{equation}
q=q_w+q_x\mathbf i+q_y\mathbf j+q_z\mathbf k;
\end{equation}
\item active vector rotation by a unit quaternion,
\begin{equation}
\boxed{\mathbf v'=q\mathbf v q^*.}
\end{equation}
\end{enumerate}
When a software library stores components in scalar-last order
$[q_x,q_y,q_z,q_w]^T$, the storage layout changes but the multiplication law
and composition rules do not.

\section{Successive active rotations}

Let $q_1$ and $q_2$ be unit quaternions.  Suppose that $q_1$ acts first on the
vector $\mathbf v$, and then $q_2$ acts on the result.  The intermediate vector is
\begin{equation}
\mathbf v_1=q_1\mathbf v q_1^*,
\end{equation}
and the final vector is
\begin{equation}
\mathbf v_2=q_2\mathbf v_1 q_2^*.
\end{equation}
Substituting equation (3) into equation (4) gives
\begin{equation}
\mathbf v_2=q_2(q_1\mathbf v q_1^*)q_2^*.
\end{equation}
Associativity of quaternion multiplication allows the factors to be regrouped:
\begin{equation}
\mathbf v_2=(q_2q_1)\mathbf v (q_1^*q_2^*).
\end{equation}
Because conjugation reverses order,
\begin{equation}
(q_2q_1)^*=q_1^*q_2^*,
\end{equation}
so the final result can be written as
\begin{equation}
\boxed{\mathbf v_2=(q_2q_1)\mathbf v (q_2q_1)^*.}
\end{equation}
Therefore the single unit quaternion equivalent to ``first $q_1$, then $q_2$'' is
\begin{equation}
\boxed{q_{\mathrm{net}}=q_2q_1.}
\end{equation}
This is the fundamental composition rule for active rotations in the
PhysicsLibrary convention.

\section{Why the order matters}

Quaternion multiplication is associative but not commutative.  Therefore,
\begin{equation}
q_2q_1\neq q_1q_2
\end{equation}
in general.  The corresponding finite rotations need not commute either.
Changing the order changes the physical result.

A simple example uses two quarter-turns.  Let
\begin{equation}
q_x=\cos\frac{\pi}{4}+\mathbf i\sin\frac{\pi}{4}
=\frac{1+\mathbf i}{\sqrt2}
\end{equation}
represent a $+90^\circ$ rotation about the $x$ axis, and let
\begin{equation}
q_y=\cos\frac{\pi}{4}+\mathbf j\sin\frac{\pi}{4}
=\frac{1+\mathbf j}{\sqrt2}
\end{equation}
represent a $+90^\circ$ rotation about the $y$ axis.

For the initial vector $\mathbf v=\hat{\mathbf z}=\mathbf k$,
\begin{equation}
q_y(q_x\mathbf k q_x^*)q_y^*=-\mathbf j,
\end{equation}
whereas
\begin{equation}
q_x(q_y\mathbf k q_y^*)q_x^*=\mathbf i.
\end{equation}
Thus
\begin{equation}
\boxed{q_yq_x\neq q_xq_y,}
\end{equation}
and the two orders send the same initial vector to different final vectors.
Figure~\ref{fig:q08-order} illustrates this noncommutativity.

\begin{figure}[h]
\centering
\includegraphics[width=0.86\textwidth]{Composition of Rotations Order Matters.png}
\caption{Composition of two active quarter-turn rotations.  The initial vector
is $\mathbf v=\hat{\mathbf z}$.  Rotating first about $x$ and then about $y$
gives $-\hat{\mathbf y}$, while rotating first about $y$ and then about $x$
gives $\hat{\mathbf x}$.  For active rotations the net quaternion is ordered in
time as $q_{\mathrm{net}}=q_2q_1$, where $q_1$ acts first.}
\label{fig:q08-order}
\end{figure}

\section{Relation to matrix composition}

If $R(q)$ denotes the direction-cosine matrix corresponding to the active unit
quaternion $q$, then
\begin{equation}
\mathbf v'=R(q)\mathbf v.
\end{equation}
Applying $q_1$ and then $q_2$ gives
\begin{equation}
\mathbf v_2=R(q_2)R(q_1)\mathbf v.
\end{equation}
Comparing equations (7) and (15), one obtains the homomorphism property
\begin{equation}
\boxed{R(q_2q_1)=R(q_2)R(q_1).}
\end{equation}
Thus quaternion composition follows the same written order as active matrix
composition: the factor nearest the vector acts first.

\section{Intrinsic and extrinsic viewpoints}

The same physical sequence can often be described in two ways.

\subsection*{Extrinsic rotations}

An \emph{extrinsic} description rotates an object about axes fixed in the
reference frame.  In this language, ``rotate by $q_1$ about a fixed axis, then
rotate by $q_2$ about another fixed axis'' leads directly to
$q_{\mathrm{net}}=q_2q_1$.

\subsection*{Intrinsic rotations}

An \emph{intrinsic} description rotates an object about axes attached to the
body after the previous rotations have occurred.  The sequence of axis labels is
then read in the moving frame.  Intrinsic and extrinsic descriptions can denote
the same overall orientation, but one must be precise about which frame each
axis belongs to.

For quaternion algebra, the safest practice is to avoid relying only on the
words intrinsic and extrinsic.  Instead, write either the explicit active
rotation chain or the explicit frame chain.

\section{Frame-chain notation}

For frame transformations it is helpful to write the source and target frames in
the quaternion symbol.  Let ${}^{A}q_B$ denote the unit quaternion that maps
coordinates from frame $B$ to frame $A$.  If a vector has coordinates
${}^{B}\mathbf v$ in frame $B$, then
\begin{equation}
{}^{A}\mathbf v={}^{A}q_B\,{}^{B}\mathbf v\,({}^{A}q_B)^*.
\end{equation}
If one then maps from frame $A$ to frame $N$, the second rotation is
${}^{N}q_A$, and the full chain is
\begin{equation}
{}^{N}\mathbf v={}^{N}q_A\left({}^{A}q_B\,{}^{B}\mathbf v\,({}^{A}q_B)^*\right)({}^{N}q_A)^*.
\end{equation}
By the same regrouping argument used earlier,
\begin{equation}
{}^{N}\mathbf v=\left({}^{N}q_A{}^{A}q_B\right){}^{B}\mathbf v\left({}^{N}q_A{}^{A}q_B\right)^*,
\end{equation}
so the frame-chain rule is
\begin{equation}
\boxed{{}^{N}q_B={}^{N}q_A{}^{A}q_B.}
\end{equation}
This mirrors the familiar matrix relation
$C^N_B=C^N_A C^A_B$.

\section{Passive interpretation}

In a passive interpretation one changes the coordinates used to describe the
same geometric vector rather than physically rotating the vector itself.  With
PhysicsLibrary's active convention as primary, the passive change associated
with $q$ is expressed by the inverse action,
\begin{equation}
\boxed{\mathbf v_{\mathrm{passive}}=q^*\mathbf v q.}
\end{equation}
The active and passive viewpoints are equivalent descriptions of the same
orientation change, but the order of factors and the meaning of the axis labels
must be handled consistently.

\section{A useful axis-angle composition formula}

If
\begin{equation}
q_1=a_1+\mathbf b_1,
\qquad
q_2=a_2+\mathbf b_2,
\end{equation}
with both quaternions unit, then their product is
\begin{equation}
q_2q_1=\bigl(a_2a_1-\mathbf b_2\cdot\mathbf b_1\bigr)
+\bigl(a_2\mathbf b_1+a_1\mathbf b_2+\mathbf b_2\times\mathbf b_1\bigr).
\end{equation}
Thus the composed axis-angle pair may be extracted from the scalar and vector
parts of $q_2q_1$.  There is no simple rule saying ``add the axes'' or ``add the
angles'' except in special commuting cases such as repeated rotations about the
same axis.

\section{Special cases and checks}

Several checks are worth memorizing.
\begin{enumerate}
\item If $q_1=1$, then $q_{\mathrm{net}}=q_2$.
\item If $q_2=1$, then $q_{\mathrm{net}}=q_1$.
\item If $q_1$ and $q_2$ are rotations about the same axis,
\begin{equation}
q_2q_1=\cos\frac{\theta_1+\theta_2}{2}+\widehat{\mathbf u}\sin\frac{\theta_1+\theta_2}{2},
\end{equation}
so the physical angles add.
\item If $q_2=q_1^*$, then
\begin{equation}
q_2q_1=1,
\end{equation}
so the second rotation exactly undoes the first.
\end{enumerate}

\section{Common pitfalls}

The most common mistakes are:
\begin{enumerate}
\item reversing the order and using $q_1q_2$ when the intended sequence is
first $q_1$, then $q_2$;
\item mixing active and passive interpretations without inverting the
quaternion;
\item confusing scalar-first display with scalar-last storage;
\item describing an intrinsic sequence but computing an extrinsic one;
\item assuming finite rotations commute because small-angle infinitesimal
rotations often appear to commute to first order.
\end{enumerate}

\section{What comes next}

The next entry derives the direction-cosine matrix associated with a unit
quaternion and shows how matrix and quaternion composition are related in
component form.

\section{Sources and historical notes}

The active composition rule follows directly from quaternion associativity and
conjugate order reversal.  The engineer-facing convention discipline is closely
aligned with the modern discussion by Sommer and coauthors on quaternion
multiplication conventions and homomorphism properties.  The use of frame-chain
notation is also consistent with standard multibody and navigation practice.

\section*{License}

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