Physics Library
 An open source physics library
Encyclopedia | Forums | Docs | Random  

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

BqA

maps coordinates from frame A into frame B, and

CqB

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

CqA =  CqB BqA.
(1)

This is the fundamental PhysicsLibrary composition rule.

The same written order appears for passive direction cosine matrices:

C C  = C C  BC  .
   A      B    A
(2)

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

A −→  B  −→  C.

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

q q ⁄=  q q .
 2 1    1 2
(3)

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

1 Convention declaration

PhysicsLibrary uses Hamilton multiplication,

ij = k,    jk =  i,     ki = j,

with reversed products changing sign.

Quaternion components are displayed scalar first:

                                 ⌊ qw⌋
                                 |   |
q = qw + qxi + qyj + qzk  ← →    | qx| .
                                 ⌈ qy⌉
                                   qz
(4)

For a positive frame rotation through angle 𝜃 about unit axis u, the passive elementary quaternion is

qP(^u, 𝜃) = cos 𝜃-− ^u sin 𝜃-.
              2        2
(5)

The passive coordinate action is

B    B    A  B    ∗
 v =   qA  v(  qA) .
(6)

The corresponding positive active rotor is the conjugate,

  A     P ∗       𝜃-       𝜃-
q  =  (q )  = cos 2 + ^usin 2.
(7)

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

2 Derivation of the passive frame chain

Suppose the first coordinate transformation is

B    B    A  B    ∗
 v =   qA  v(  qA) .
(8)

Now transform the same physical vector from frame B into frame C:

Cv = C qB Bv (C qB)∗.
(9)

Substitute equation (8) into equation (9):

C v = CqB (BqA Av (BqA )∗) (CqB)∗.

Associativity allows the factors to be regrouped:

C     (C   B   )A  ( B    ∗C    ∗)
  v =   qB  qA   v  ( qA )(  qB)  .

Quaternion conjugation reverses product order:

(        )
 CqB BqA  ∗ = (BqA)∗(CqB )∗.
(10)

Therefore

C v = (Cq  Bq  )Av (Cq  Bq  )∗.
         B   A        B    A
(11)

Comparing this with the canonical passive sandwich gives

CqA =  CqB BqA.
(12)

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

3 Longer frame chains

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

A  −→  B − →  C −→  D,

the direct quaternion is

DqA =  DqC CqB BqA.
(13)

Applied to a vector,

Dv = DqA  Av(DqA )∗.

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:

DqC C qB BqA.

The adjacent frame names form the chain

A  →  B →  C →  D.

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

4 Inverse of a frame chain

Starting with

Cq  =  Cq  Bq  ,
  A      B   A

take the inverse:

(C qA)−1 = (BqA )− 1(C qB)−1.

Since frame quaternions are unit,

 − 1    ∗
q   = q .

Relabeling the reverse maps gives

A      A   B
 qC =   qB  qC .
(14)

Thus reversing the frame chain also reverses the multiplication order.

The forward sequence

A  →  B →  C

becomes

C  → B  →  A.

5 Relation to passive matrix composition

Let

BCA  =  C(BqA )
(15)

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

Then

Bv =  BCA Av.
(16)

Two successive frame maps give

C v = CCB  Bv
      C    B    A
    =  CB   CA   v.

Therefore

C CA = C CB BCA.
(17)

Comparing with equation (13) gives the homomorphism relation

  (        )
C  CqB BqA  =  C(C qB)C (BqA ).
(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.

6 Why finite rotations do not commute

Consider the elementary passive quaternions for positive 90∘ frame rotations about the coordinate x and y axes:

     1 − i
qx = -√---,
        2
(19)

q  = 1√−-j.
 y      2
(20)

Their products are

       1
qyqx = 2(1 − j)(1 − i)
       1
    =  --(1 − i − j + ji)
       2
    =  1-(1 − i − j − k ),
       2

while

       1
qxqy = -(1 − i)(1 − j)
       21
    =  --(1 − i − j + ij)
       2
       1-
    =  2 (1 − i − j + k ).

Therefore

qyqx ⁄= qxqy.
(21)

The sign of the k component changes.

7 Vector check of noncommutativity

Use the initial pure quaternion

v = k.

Apply qx first and then qy. The combined passive operator is

q q .
 y x

The first map sends

k −→  j,

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

(qyqx)k (qyqx)∗ = j.
(22)

Reverse the order. The combined operator is

qxqy.

The y map first sends

k −→  − i,

and the subsequent x map leaves i unchanged. Hence

(qxqy)k (qxqy)∗ = − i.
(23)

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

j ⁄= − i.

This is a direct observable consequence of noncommutativity.

PIC

Figure 1:Order matters for successive passive frame rotations. Starting with Av = k, applying the positive 90∘ passive x frame map first and the positive 90∘ passive y frame map second gives Cv = j and q net = qyqx. Reversing the order gives Cv = −i and q net = qxqy.

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

8 Associative but not commutative

Quaternion multiplication is associative:

(q3q2)q1 = q3(q2q1).
(24)

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

Quaternion multiplication is not commutative:

q2q1 ⁄= q1q2
(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.

9 Comparison with successive active rotations

The active counterpart obeys the same basic product pattern.

Let r1 actively rotate a physical vector first and let r2 act second:

v1 = r1vr ∗1

and

v =  r v r∗.
 2    2 1 2

Substitution gives

                 ∗
v2 = (r2r1)v(r2r1).

Therefore

r   =  rr .
 net    21
(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,

      P ∗
r = (q ) .
(27)

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

10 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

CqA =  CqB BqA.

11 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.

12 Generic intrinsic i  -j  -k  sequence

Let an intrinsic sequence consist of:

  1. a rotation α about the initial moving axis i;
  2. a rotation β about the new moving axis j;
  3. a rotation γ about the final moving axis k.

Define the passive elementary quaternions

 P           α-        α-
qi (α) = cos 2 − eisin 2,
(28)

 P          β          β
qj (β) = cos-- − ej sin-,
             2         2
(29)

and

            γ          γ
qPk (γ) = cos--−  ek sin-.
             2         2
(30)

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

B      P     P    P
 qA = qk (γ)qj (β)qi (α).
(31)

The corresponding passive DCM is

BCA  =  Ck(γ)Cj (β)Ci(α).
(32)

Quaternion and DCM sequence order therefore agree exactly.

13 Intrinsic and extrinsic equivalence

The intrinsic sequence

i then j then k

with angles

α,β,γ

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

k then j then i

with angles

γ, β,α.

Symbolically,

Intrinsic i− j− k (α, β,γ ) ≡ Extrinsic k− j− i (γ,β,α ).
(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.

14 Aerospace intrinsic 3  -2  -1  example

For the common intrinsic 3-2-1 sequence, PhysicsLibrary uses

ψ  = yaw,     𝜃 = pitch,     ϕ = roll.

The rotations occur intrinsically as

3 then 2 then  1.

The passive quaternion is

BqA = qP1 (ϕ)qP2 (𝜃)qP3 (ψ ).
(34)

The passive DCM uses the same order:

BCA  =  C1(ϕ)C2 (𝜃)C3(ψ).
(35)

This is equivalent to an extrinsic fixed axis 1-2-3 description with angles ϕ,𝜃,ψ 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.

15 Useful scalar vector composition formula

Let

q  = a  + b  ,    q  = a  + b .
 1     1    1      2    2    2

Hamilton multiplication gives

q2q1 = (a2a1 − b2 ⋅ b1) + (a2b1 + a1b2 + b2 × b1) .
(36)

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

For passive elementary rotations,

             𝜃1
b1 = − ^u1 sin  2

and

             𝜃2
b2 = − ^u2sin 2 .

Thus the scalar part of the net quaternion is

anet = c2c1 − s2s1^u2 ⋅ ^u1,
(37)

where

         𝜃i             𝜃i
ci = cos --,    si = sin --.
         2              2

The vector part is

bnet =  − c2s1^u1 − c1s2^u2

        + s2s1(^u2 × ^u1) .
(38)

Once qnet is normalized and its principal sign is selected, the passive net axis can be recovered from

^u   =  − -bnet--
  net     ∥bnet∥
(39)

when the vector part is nonzero.

16 Special case: rotations about the same axis

Let both passive rotations use the same unit axis u:

        𝜃1         𝜃1
q1 = cos 2 − ^u sin 2 ,

        𝜃2         𝜃2
q2 = cos 2 − ^u sin 2 .

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

Direct multiplication gives

           𝜃1 + 𝜃2       𝜃1 + 𝜃2
q2q1 = cos -------− ^u sin-------.
             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.

17 Special case: inverse rotations

If

q =  q−1 = q∗,
 2    1     1

then

q2q1 = 1.
(41)

The second transformation exactly reverses the first.

For a frame chain,

Aq  Bq   = 1.
   B   A

This is an important implementation check.

18 Small rotations and approximate commutativity

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

Let

         1
q1 ≈ 1 − --𝜃1
         2

and

         1-
q2 ≈ 1 − 2𝜃2,

where the rotation vectors are pure quaternions.

Multiplying and retaining terms through second order gives

           1-
q2q1 ≈ 1 − 2(𝜃1 + 𝜃2)
          1
       +  -𝜃2𝜃1.
          4

Reversing the order changes only the second order product term.

The difference is related to the cross product:

q q − q q  ≈  1(𝜃  × 𝜃 ) .
 2 1   1 2    2   2    1
(42)

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

19 Implementation guidance

When composing quaternion transformations in software:

  1. Document what the quaternion maps. For PhysicsLibrary, Bq A means coordinates A → 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 90∘ rotation about each coordinate axis.
  7. Verify the inverse relation

    A      B    ∗
 qB = (  qA) .
  8. For an Euler sequence, write whether the axes are intrinsic moving axes or extrinsic fixed axes.

20 Common pitfalls

  1. Using the old PhysicsLibrary frame notation direction.

    The current house convention is

    BqA : A →  B.
  2. Reversing a valid frame chain.

    The correct chain is

    CqA =  CqB BqA.
  3. Assuming finite rotations commute.

    In general,

    q2q1 ⁄= q1q2.
  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 i-j-k sequence,

    BqA = qPk (γ)qPj (β)qPi (α).
  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.

21 Verification cases

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

  1. identity on either side:

    1q = q1 = q.
  2. Inverse pair:

     ∗      ∗
q q = qq =  1.
  3. Same axis rotations add angles.
  4. Positive 90∘ passive x and y 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 3-2-1 quaternion and DCM products use the same written factor order.

22 Relationship to adjacent PhysicsLibrary entries

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

Bv = BqA  Av(BqA )∗.

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.

23 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.

References

[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

[2]   C. J. Joly, A Manual of Quaternions, Macmillan and Co., London, 1905. Public domain historical source. Internet Archive scan

[3]   A. S. Hathaway, A Primer of Quaternions, 1896. Public domain historical source. Project Gutenberg edition

[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

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, Quaternions for Physics and Engineering: Orientation, Notation, and Conventions, 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, observable, operator, matrix, conjugation, scalar, vector, quaternion multiplication, direction cosine matrices, composition, algorithm, systems, relation, quaternion, unit
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 343 times total.

Classification:
Physics Classification: 02.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

No messages.

Interact