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
composition of rotations and quaternion order (Definition)

Composition of Rotations and Quaternion Order

A single unit quaternion describes one orientation relation. Real systems, however, almost always involve a sequence of rotations or frame transformations. A body may receive several attitude commands, a navigation algorithm may transform through several coordinate frames, or an Euler sequence may build an orientation through three successive elementary rotations.

The important question is therefore not merely how to construct one quaternion, but how quaternion transformations compose and which factor acts first.

PhysicsLibrary uses passive frame quaternions as the canonical attitude objects. If

$\displaystyle {}^{B}q_A $

maps coordinates from frame $A$ into frame $B$, and

$\displaystyle {}^{C}q_B $

maps coordinates from frame into frame $C$, then the direct map from into is

$\displaystyle {}^{C}q_A = {}^{C}q_B\,{}^{B}q_A.$ (1)

This is the fundamental PhysicsLibrary composition rule.

The same written order appears for passive direction cosine matrices:

$\displaystyle {}^{C}C_A = {}^{C}C_B\,{}^{B}C_A.$ (2)

The frame labels provide the safest guide to multiplication order. Reading from right to left, the coordinate map proceeds

$\displaystyle A\longrightarrow B\longrightarrow C. $

Quaternion multiplication is associative but not commutative. Therefore two finite rotations generally cannot be exchanged:

$\displaystyle q_2q_1 \neq q_1q_2.$ (3)

This noncommutativity is not an abstract inconvenience. It changes the final physical orientation and the transformed vector coordinates.

Convention declaration

PhysicsLibrary uses Hamilton multiplication,

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

with reversed products changing sign.

Quaternion components are displayed scalar first:

$\displaystyle q = q_w+q_x\mathbf i+q_y\mathbf j+q_z\mathbf k \quad\longleftrightarrow\quad \begin{bmatrix} q_w\ q_x\ q_y\ q_z \end{bmatrix}.$ (4)

For a positive frame rotation through angle $\theta$ about unit axis $\widehat{\mathbf u}$, the passive elementary quaternion is

$\displaystyle q^{P}(\widehat{\mathbf u},\theta) = \cos\frac{\theta}{2} - \widehat{\mathbf u}\sin\frac{\theta}{2}.$ (5)

The passive coordinate action is

$\displaystyle {}^{B}v = {}^{B}q_A\,{}^{A}v\,({}^{B}q_A)^*.$ (6)

The corresponding positive active rotor is the conjugate,

$\displaystyle q^{A} = (q^{P})^* = \cos\frac{\theta}{2} + \widehat{\mathbf u}\sin\frac{\theta}{2}.$ (7)

Hamilton multiplication itself is unchanged by choosing an active or passive interpretation.

Derivation of the passive frame chain

Suppose the first coordinate transformation is

(8)

Now transform the same physical vector from frame into frame :

$\displaystyle {}^{C}v = {}^{C}q_B\,{}^{B}v\,({}^{C}q_B)^*.$ (9)

Substitute equation (8) into equation (9):

$\displaystyle {}^{C}v = {}^{C}q_B \left( {}^{B}q_A\,{}^{A}v\,({}^{B}q_A)^* \right) ({}^{C}q_B)^*. $

Associativity allows the factors to be regrouped:

$\displaystyle {}^{C}v = \left( {}^{C}q_B\,{}^{B}q_A \right) {}^{A}v \left( ({}^{B}q_A)^*({}^{C}q_B)^* \right). $

Quaternion conjugation reverses product order:

$\displaystyle \left( {}^{C}q_B\,{}^{B}q_A \right)^* = ({}^{B}q_A)^* ({}^{C}q_B)^*.$ (10)

Therefore

$\displaystyle {}^{C}v = \left( {}^{C}q_B\,{}^{B}q_A \right) {}^{A}v \left( {}^{C}q_B\,{}^{B}q_A \right)^*.$ (11)

Comparing this with the canonical passive sandwich gives

(12)

No ad hoc reversal rule is needed. The composition order follows directly from the frame map definition.

Longer frame chains

The same rule extends immediately to any number of frames. For

$\displaystyle A\longrightarrow B\longrightarrow C\longrightarrow D, $

the direct quaternion is

$\displaystyle {}^{D}q_A = {}^{D}q_C\, {}^{C}q_B\, {}^{B}q_A.$ (13)

Applied to a vector,

$\displaystyle {}^{D}v = {}^{D}q_A\,{}^{A}v\,({}^{D}q_A)^*. $

The factor nearest the vector describes the first coordinate map. Each successive map appears farther to the left.

The frame labels provide a visual consistency check:

$\displaystyle {}^{D}q_C \, {}^{C}q_B \, {}^{B}q_A. $

The adjacent frame names form the chain

$\displaystyle A\rightarrow B\rightarrow C\rightarrow D. $

The labels are not algebraically cancelled like scalar fractions, but their pattern is an effective mnemonic for detecting an incorrectly ordered chain.

Inverse of a frame chain

Starting with

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

take the inverse:

$\displaystyle ({}^{C}q_A)^{-1} = ({}^{B}q_A)^{-1} ({}^{C}q_B)^{-1}. $

Since frame quaternions are unit,

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

Relabeling the reverse maps gives

$\displaystyle {}^{A}q_C = {}^{A}q_B\,{}^{B}q_C.$ (14)

Thus reversing the frame chain also reverses the multiplication order.

The forward sequence

$\displaystyle A\rightarrow B\rightarrow C $

becomes

$\displaystyle C\rightarrow B\rightarrow A. $

Relation to passive matrix composition

Let

$\displaystyle {}^{B}C_A = C({}^{B}q_A)$ (15)

be the passive direction cosine matrix associated with the frame quaternion.

Then

$\displaystyle {}^{B}\mathbf v = {}^{B}C_A\,{}^{A}\mathbf v.$ (16)

Two successive frame maps give

\begin{equation*} \begin{aligned} {}^{C}\mathbf v &= {}^{C}C_B\,{}^{B}\mathbf v\ &= {}^{C}C_B\,{}^{B}C_A\,{}^{A}\mathbf v. \end{aligned}\end{equation*}

Therefore

(17)

Comparing with equation (13) gives the homomorphism relation

$\displaystyle C \left( {}^{C}q_B\,{}^{B}q_A \right) = C({}^{C}q_B) C({}^{B}q_A).$ (18)

Quaternion and matrix chains therefore use the same written order under the PhysicsLibrary passive convention.

This alignment is one of the main reasons for choosing the present frame quaternion notation.

Why finite rotations do not commute

Consider the elementary passive quaternions for positive $90^\circ$ frame rotations about the coordinate $x$ and $y$ axes:

$\displaystyle q_x = \frac{1-\mathbf i}{\sqrt2},$ (19)
$\displaystyle q_y = \frac{1-\mathbf j}{\sqrt2}.$ (20)

Their products are

\begin{equation*} \begin{aligned} q_yq_x &= \frac12 (1-\mathbf j)(1-\mathbf i)\\... ...c12 \left( 1-\mathbf i-\mathbf j-\mathbf k \right), \end{aligned}\end{equation*}

while

\begin{equation*} \begin{aligned} q_xq_y &= \frac12 (1-\mathbf i)(1-\mathbf j)\\... ...c12 \left( 1-\mathbf i-\mathbf j+\mathbf k \right). \end{aligned}\end{equation*}

Therefore

$\displaystyle q_yq_x \neq q_xq_y.$ (21)

The sign of the $\mathbf k$ component changes.

Vector check of noncommutativity

Use the initial pure quaternion

$\displaystyle v=\mathbf k. $

Apply $q_x$ first and then $q_y$. The combined passive operator is

$\displaystyle q_yq_x. $

The first map sends

$\displaystyle \mathbf k\longrightarrow\mathbf j, $

and the second leaves $\mathbf j$ unchanged because it lies along the second rotation axis. Thus

$\displaystyle (q_yq_x)\mathbf k(q_yq_x)^* = \mathbf j.$ (22)

Reverse the order. The combined operator is

$\displaystyle q_xq_y. $

The map first sends

$\displaystyle \mathbf k\longrightarrow-\mathbf i, $

and the subsequent map leaves $\mathbf i$ unchanged. Hence

$\displaystyle (q_xq_y)\mathbf k(q_xq_y)^* = -\mathbf i.$ (23)

The same initial vector therefore gives two different final coordinate vectors:

$\displaystyle \mathbf j \neq -\mathbf i. $

This is a direct observable consequence of noncommutativity.

Figure: Order matters for successive passive frame rotations. Starting with ${}^{A}\mathbf v=\mathbf k$, applying the positive passive frame map first and the positive passive frame map second gives ${}^{C}\mathbf v=\mathbf j$ and $q_{\mathrm{net}}=q_yq_x$. Reversing the order gives ${}^{C}\mathbf v=-\mathbf i$ and $q_{\mathrm{net}}=q_xq_y$.
Image Composition of Rotations Order Matters

Figure [*] summarizes both quaternion products and their different actions on the same initial coordinate vector.

Associative but not commutative

Quaternion multiplication is associative:

$\displaystyle (q_3q_2)q_1 = q_3(q_2q_1).$ (24)

This means parentheses may be moved without changing a valid composition chain.

Quaternion multiplication is not commutative:

$\displaystyle q_2q_1 \neq q_1q_2$ (25)

in general.

These two facts have different practical meanings:

  • Associativity allows a long frame chain to be grouped for computational convenience.
  • Noncommutativity means the chronological or frame sequence itself cannot normally be rearranged.

Comparison with successive active rotations

The active counterpart obeys the same basic product pattern.

Let $r_1$ actively rotate a physical vector first and let $r_2$ act second:

$\displaystyle v_1=r_1vr_1^* $

and

$\displaystyle v_2=r_2v_1r_2^*. $

Substitution gives

$\displaystyle v_2 = (r_2r_1)v(r_2r_1)^*. $

Therefore

$\displaystyle r_{\mathrm{net}} = r_2r_1.$ (26)

The important distinction is not the abstract product law. It is the quaternion associated with a positive geometric rotation.

For the same positive axis and angle,

$\displaystyle r = (q^{P})^*.$ (27)

Thus a positive active rotor has the opposite vector sign from the corresponding positive passive frame quaternion.

Do not infer order from the words active or passive

It is tempting to memorize statements such as “active reverses order” or “passive keeps order.” Such slogans are unreliable because authors define their quaternion symbols, map directions, and axis descriptions differently.

The safe procedure is:

  1. state what each quaternion maps;
  2. write the action on a vector;
  3. substitute successive transformations;
  4. use associativity;
  5. identify the resulting net quaternion.

For PhysicsLibrary's canonical passive notation, this procedure yields

Intrinsic and extrinsic rotations

The words intrinsic and extrinsic describe which axes are used for successive elementary rotations.

An intrinsic sequence uses axes attached to the moving frame. After the first rotation, the second axis has moved with the frame; after the second rotation, the third axis has moved again.

An extrinsic sequence uses axes fixed in the reference frame.

The same final orientation can be described either way if the axis sequence and angle order are reversed appropriately. Therefore the words alone are not sufficient to determine quaternion multiplication order.

PhysicsLibrary uses intrinsic moving axis language for Euler sequences unless an article explicitly states otherwise.

Generic intrinsic $i$-$j$-$k$ sequence

Let an intrinsic sequence consist of:

  1. a rotation $\alpha$ about the initial moving axis ;
  2. a rotation $\beta$ about the new moving axis ;
  3. a rotation $\gamma$ about the final moving axis .

Define the passive elementary quaternions

$\displaystyle q_i^{P}(\alpha) = \cos\frac{\alpha}{2} - \mathbf e_i\sin\frac{\alpha}{2},$ (28)
$\displaystyle q_j^{P}(\beta) = \cos\frac{\beta}{2} - \mathbf e_j\sin\frac{\beta}{2},$ (29)

and

$\displaystyle q_k^{P}(\gamma) = \cos\frac{\gamma}{2} - \mathbf e_k\sin\frac{\gamma}{2}.$ (30)

Under the PhysicsLibrary moving axis convention, the total passive frame quaternion is

$\displaystyle {}^{B}q_A = q_k^{P}(\gamma) q_j^{P}(\beta) q_i^{P}(\alpha).$ (31)

The corresponding passive DCM is

$\displaystyle {}^{B}C_A = C_k(\gamma) C_j(\beta) C_i(\alpha).$ (32)

Quaternion and DCM sequence order therefore agree exactly.

Intrinsic and extrinsic equivalence

The intrinsic sequence

$\displaystyle i$ then $\displaystyle j$ then $\displaystyle k $

with angles

$\displaystyle \alpha,\beta,\gamma $

describes the same final orientation as an extrinsic sequence about the fixed axes

then  then 

with angles

$\displaystyle \gamma,\beta,\alpha. $

Symbolically,

$\displaystyle \mathrm{Intrinsic}\ i\!-\!j\!-\!k \;(\alpha,\beta,\gamma) \equiv \mathrm{Extrinsic}\ k\!-\!j\!-\!i \;(\gamma,\beta,\alpha).$ (33)

This equivalence is a statement about how the same geometric orientation is described. It does not mean the original sequence can be arbitrarily reordered.

Aerospace intrinsic $3$-$2$-$1$ example

For the common intrinsic -- sequence, PhysicsLibrary uses

$\displaystyle \psi=$yaw$\displaystyle , \qquad \theta=$pitch$\displaystyle , \qquad \phi=$roll$\displaystyle . $

The rotations occur intrinsically as

$\displaystyle 3$ then $\displaystyle 2$ then $\displaystyle 1. $

The passive quaternion is

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

The passive DCM uses the same order:

$\displaystyle {}^{B}C_A = C_1(\phi) C_2(\theta) C_3(\psi).$ (35)

This is equivalent to an extrinsic fixed axis -- description with angles $\phi,\theta,\psi$ applied in the corresponding reversed viewpoint.

Writing the product explicitly is safer than relying on the phrase “yaw pitch roll,” because software and textbooks differ in how they use that phrase.

Useful scalar vector composition formula

Let

$\displaystyle q_1=a_1+\mathbf b_1, \qquad q_2=a_2+\mathbf b_2. $

Hamilton multiplication gives

$\displaystyle q_2q_1 = \left( a_2a_1-\mathbf b_2\cdot\mathbf b_1 \right) + \left( a_2\mathbf b_1 + a_1\mathbf b_2 + \mathbf b_2\times\mathbf b_1 \right).$ (36)

This formula is useful for computing the net axis angle representation after two rotations.

For passive elementary rotations,

$\displaystyle \mathbf b_1 = -\widehat{\mathbf u}_1 \sin\frac{\theta_1}{2} $

and

$\displaystyle \mathbf b_2 = -\widehat{\mathbf u}_2 \sin\frac{\theta_2}{2}. $

Thus the scalar part of the net quaternion is

$\displaystyle a_{\mathrm{net}} = c_2c_1 - s_2s_1 \widehat{\mathbf u}_2\cdot\widehat{\mathbf u}_1,$ (37)

where

$\displaystyle c_i=\cos\frac{\theta_i}{2}, \qquad s_i=\sin\frac{\theta_i}{2}. $

The vector part is

\begin{equation*}\begin{aligned} \mathbf b_{\mathrm{net}} ={}& -c_2s_1\widehat{\... ...at{\mathbf u}_2\times\widehat{\mathbf u}_1 \right). \end{aligned}\end{equation*}

Once $q_{\mathrm{net}}$ is normalized and its principal sign is selected, the passive net axis can be recovered from

$\displaystyle \widehat{\mathbf u}_{\mathrm{net}} = -\frac{\mathbf b_{\mathrm{net}}} {\lVert\mathbf b_{\mathrm{net}}\rVert}$ (39)

when the vector part is nonzero.

Special case: rotations about the same axis

Let both passive rotations use the same unit axis :

$\displaystyle q_1 = \cos\frac{\theta_1}{2} - \widehat{\mathbf u} \sin\frac{\theta_1}{2}, $

$\displaystyle q_2 = \cos\frac{\theta_2}{2} - \widehat{\mathbf u} \sin\frac{\theta_2}{2}. $

Because both quaternions lie in the same two dimensional subalgebra generated by and , they commute.

Direct multiplication gives

$\displaystyle q_2q_1 = \cos \frac{\theta_1+\theta_2}{2} - \widehat{\mathbf u} \sin \frac{\theta_1+\theta_2}{2}.$ (40)

Therefore rotations about the same axis add their angles.

This is a special commuting case. It should not be generalized to rotations about different axes.

Special case: inverse rotations

If

$\displaystyle q_2=q_1^{-1}=q_1^*, $

then

$\displaystyle q_2q_1=1.$ (41)

The second transformation exactly reverses the first.

For a frame chain,

$\displaystyle {}^{A}q_B\,{}^{B}q_A=1. $

This is an important implementation check.

Small rotations and approximate commutativity

Finite rotations do not generally commute, but very small rotations can appear to commute to first order.

Let

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

and

$\displaystyle q_2 \approx 1-\frac12\boldsymbol\theta_2, $

where the rotation vectors are pure quaternions.

Multiplying and retaining terms through second order gives

\begin{equation*} \begin{aligned} q_2q_1 \approx{}& 1 -\frac12 (\boldsymbol\thet... ... &+ \frac14 \boldsymbol\theta_2\boldsymbol\theta_1. \end{aligned}\end{equation*}

Reversing the order changes only the second order product term.

The difference is related to the cross product:

$\displaystyle q_2q_1-q_1q_2 \approx \frac12 \left( \boldsymbol\theta_2\times \boldsymbol\theta_1 \right).$ (42)

Thus noncommutativity disappears only at first order. This is why infinitesimal rotation calculations may look commutative even though finite attitude updates are not.

Implementation guidance

When composing quaternion transformations in software:

  1. Document what the quaternion maps. For PhysicsLibrary, ${}^{B}q_A$ means coordinates $A\rightarrow B$.
  2. Document Hamilton multiplication separately from component storage.
  3. Write frame labels in design notes even if the software type does not encode them.
  4. Build long chains in the same order as the corresponding passive DCM chain.
  5. Do not reorder factors for computational convenience unless the quaternions are known to commute.
  6. When converting from an external library, test a positive rotation about each coordinate axis.
  7. Verify the inverse relation

    $\displaystyle {}^{A}q_B = ({}^{B}q_A)^*. $
  8. For an Euler sequence, write whether the axes are intrinsic moving axes or extrinsic fixed axes.

Common pitfalls

  1. Using the old PhysicsLibrary frame notation direction.

    The current house convention is

    $\displaystyle {}^{B}q_A: A\rightarrow B. $
  2. Reversing a valid frame chain.

    The correct chain is

  3. Assuming finite rotations commute.

    In general,

  4. Confusing active and passive positive rotation quaternions.

    For the same positive axis and angle, they are conjugates.

  5. Changing Hamilton multiplication to repair a frame convention problem.

    PhysicsLibrary retains Hamilton multiplication. Frame direction is encoded in the quaternion symbol and in the sign of the positive passive elementary rotation.

  6. Treating intrinsic and extrinsic as synonyms.

    Intrinsic axes move with the rotating frame. Extrinsic axes remain fixed in the reference frame.

  7. Using an intrinsic axis list with an extrinsic product.

    For PhysicsLibrary's intrinsic -- sequence,

  8. Inferring multiplication convention from scalar first or scalar last storage.

    Memory layout does not determine quaternion multiplication.

  9. Assuming small angle commutativity holds for finite updates.

    The noncommuting cross product term appears at second order and becomes important as rotation increments grow.

Verification cases

Several composition checks are useful to keep in a test suite.

  1. identity on either side:

    $\displaystyle 1q=q1=q. $
  2. Inverse pair:

    $\displaystyle q^*q=qq^*=1. $
  3. Same axis rotations add angles.
  4. Positive passive and maps do not commute.
  5. Replacing every quaternion in a complete sandwich by its negative does not change the represented orientation.
  6. Quaternion and DCM chains produce the same final vector coordinates.
  7. Intrinsic -- quaternion and DCM products use the same written factor order.

Relationship to adjacent PhysicsLibrary entries

The preceding article, rotating vectors with quaternions, establishes the canonical passive sandwich

The present article uses that action to derive the composition rule, frame chains, noncommutativity, and intrinsic sequence order.

A separate companion entry, Composition of Rotations and Quaternion Order: Examples, Exercises, and Solutions, provides the Q08E self study problem bank.

The next main article, quaternions and direction cosine matrices, derives the complete matrix associated with a unit quaternion and develops the inverse matrix to quaternion conversion.

Sources and convention notes

Quaternion composition follows directly from associativity and the conjugate order reversal identity. Historical quaternion texts treat products of versors and successive rotations, while modern engineering sources emphasize the need to state multiplication and frame conventions explicitly.

Sommer and coauthors provide a modern discussion of Hamilton and flipped multiplication and the homomorphism issues that arise when active and passive attitude conventions are mixed. PhysicsLibrary retains Hamilton multiplication and chooses passive frame quaternions whose composition order matches the passive direction cosine matrix chain.

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
C. J. Joly, A Manual of Quaternions, Macmillan and Co., London, 1905. Public domain historical source. Internet Archive scan https://archive.org/details/manualofquaterni00jolyrich
3
A. S. Hathaway, A Primer of Quaternions, 1896. Public domain historical source. Project Gutenberg edition https://www.gutenberg.org/ebooks/9934
4
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

License

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



"composition of rotations and quaternion order" 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, composition of rotations, rotation order, quaternion product, noncommutativity, active rotation, passive rotation, intrinsic rotations, extrinsic rotations, frame chain

Attachments:
example of composition of rotations and quaternion order (Example) by bloftin

Cross-references: quaternions and direction cosine matrices, rotating vectors with quaternions, identity, commutativity, type, cross product, commute, representation, formula, reference frame, observable, operator, matrix, conjugation, scalar, vector, quaternion multiplication, direction cosine matrices, composition, algorithm, systems, relation, quaternion
There are 4 references to this object.

This is version 3 of composition of rotations and quaternion order, born on 2026-08-23, modified 2026-08-26.
Object id is 1099, canonical name is CompositionOfRotationsAndQuaternionOrder.
Accessed 106 times total.

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

No messages.

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