3.5.7Guidance, Navigation & Control (GNC)

Quaternion product — Hamilton product

1,926 words9 min readdifficulty · medium1 backlinks

What a quaternion is

From ijk=1ijk=-1 and squaring rules, the pairwise products follow (this is the whole engine):

ij=k,jk=i,ki=j(cyclic, right-handed)ij = k,\quad jk = i,\quad ki = j \qquad\text{(cyclic, right-handed)} ji=k,kj=i,ik=j(anti-cyclic)ji = -k,\quad kj = -i,\quad ik = -j \qquad\text{(anti-cyclic)}


Deriving the Hamilton product from scratch

Figure — Quaternion product — Hamilton product

Worked example 1 — pure imaginary units

Compute iji\,j using the vector formula.

  • p=ip=i: w1=0, v1=(1,0,0)w_1=0,\ \mathbf{v}_1=(1,0,0). Why? ii is a pure-vector unit quaternion.
  • q=jq=j: w2=0, v2=(0,1,0)w_2=0,\ \mathbf{v}_2=(0,1,0).
  • scalar =0(1,0,0) ⁣ ⁣(0,1,0)=0= 0 - (1,0,0)\!\cdot\!(0,1,0) = 0. Why? v1v2\mathbf v_1 \perp \mathbf v_2, dot is 0.
  • vector =0+0+(1,0,0)×(0,1,0)=(0,0,1)= 0 + 0 + (1,0,0)\times(0,1,0) = (0,0,1). Why? right-hand cross gives z^\hat z.
  • Result =(0,(0,0,1))=k=(0,(0,0,1)) = k. ✅ matches ij=kij=k.

Now jij\,i: cross flips to (0,0,1)(0,0,-1) → result k-k. Why this step? cross product is anti-commutative, so swapping order flips sign. This proves ij=jiij=-ji.


Worked example 2 — combining two real rotations

Rotate 9090^\circ about zz, then 9090^\circ about xx. Unit quaternion for angle θ\theta about axis n^\hat n is q=(cosθ2, sinθ2n^)q = (\cos\frac\theta2,\ \sin\frac\theta2\,\hat n).

  • qz=(cos45,(0,0,sin45))=(12,0,0,12)q_z = (\cos45^\circ, (0,0,\sin45^\circ)) = (\tfrac{1}{\sqrt2}, 0,0,\tfrac{1}{\sqrt2})
  • qx=(12,12,0,0)q_x = (\tfrac{1}{\sqrt2}, \tfrac{1}{\sqrt2},0,0)

Combined rotation ("xx after zz") = qxqzq_x \, q_z (leftmost applied last). Why? Hamilton convention: qtotal=qlastqfirstq_{\text{total}} = q_{\text{last}}\,q_{\text{first}}.

  • w=w1w2v1 ⁣ ⁣v2=12(12,0,0) ⁣ ⁣(0,0,12)=120=12w = w_1w_2 - \mathbf v_1\!\cdot\!\mathbf v_2 = \tfrac12 - (\tfrac{1}{\sqrt2},0,0)\!\cdot\!(0,0,\tfrac{1}{\sqrt2}) = \tfrac12 - 0 = \tfrac12
  • v=w1v2+w2v1+v1×v2\mathbf v = w_1\mathbf v_2 + w_2\mathbf v_1 + \mathbf v_1\times\mathbf v_2 =12(0,0,12)+12(12,0,0)+(12,0,0)×(0,0,12)= \tfrac{1}{\sqrt2}(0,0,\tfrac{1}{\sqrt2}) + \tfrac{1}{\sqrt2}(\tfrac{1}{\sqrt2},0,0) + (\tfrac{1}{\sqrt2},0,0)\times(0,0,\tfrac{1}{\sqrt2}) =(0,0,12)+(12,0,0)+(0,12,0)=(12,12,12)= (0,0,\tfrac12) + (\tfrac12,0,0) + (0,-\tfrac12,0) = (\tfrac12,-\tfrac12,\tfrac12)

So qxqz=(12,12,12,12)q_xq_z = (\tfrac12, \tfrac12,-\tfrac12,\tfrac12). Check: norm =414=1=\sqrt{4\cdot\tfrac14}=1 ✅ (product of unit quaternions is unit — that's why gyro integration keeps orientations valid).


Rotating a vector

Why a sandwich and not just ququ? A single product would mix scalar and vector parts and change length. The conjugation q()q1q(\cdot)q^{-1} cancels the scalar leakage and applies the rotation twice-by-half, which is why the half-angle θ/2\theta/2 appears in qq.


Common mistakes


Recall

Recall Flashables (hide and test yourself)
  • What are the two parts of the Hamilton product? scalar =w1w2v1 ⁣ ⁣v2=w_1w_2-\mathbf v_1\!\cdot\!\mathbf v_2; vector =w1v2+w2v1+v1×v2=w_1\mathbf v_2+w_2\mathbf v_1+\mathbf v_1\times\mathbf v_2.
  • Sole source of non-commutativity? the cross product term.
  • ij=?ij=?   =k\;=k. ji=?ji=?   =k\;=-k.
  • How to rotate a vector? quqˉq\,u\,\bar q for unit qq.
Recall Feynman: explain to a 12-year-old

Imagine two magic "turn cards." Each card, when you tap it, spins a toy in space. If you want one card that does both spins at once, you glue the two cards together with a special recipe. The recipe has two ingredients: one part checks how much the two spins point the same way (that's the dot part, a plain number), and the other part checks how much they twist across each other (that's the cross part, which points sideways by the right-hand rule). Because twisting-across depends on which card you tap first, tapping card A then B is not the same as B then A — just like turning a Rubik's cube.


Connections

  • Rotation Matrices — SO(3) — the Hamilton product ≡ matrix multiplication of rotations.
  • Axis-Angle & Euler Rodrigues — where the half-angle θ/2\theta/2 inside qq comes from.
  • Quaternion Kinematics — $\dot q = \tfrac12 q\,\omega$ — gyro integration uses this product.
  • Multiplicative EKF (MEKF) — attitude filters chain Hamilton products.
  • Gimbal Lock & Euler Angles — the problem quaternions solve.
  • Cross Product & Right-Hand Rule — the geometric root of ij=kij=k.
Hamilton product scalar part
w1w2v1v2w_1w_2 - \mathbf v_1\cdot\mathbf v_2
Hamilton product vector part
w1v2+w2v1+v1×v2w_1\mathbf v_2 + w_2\mathbf v_1 + \mathbf v_1\times\mathbf v_2
Which term causes non-commutativity
the cross product v1×v2\mathbf v_1\times\mathbf v_2
Value of ijij
kk
Value of jiji
k-k
Fundamental relation defining quaternions
i2=j2=k2=ijk=1i^2=j^2=k^2=ijk=-1
Order convention: rotation A then B combined quaternion
qBqAq_B q_A (right-to-left)
How to rotate vector u by unit quaternion q
u=quqˉu' = q\,u\,\bar q
Inverse of a unit quaternion
its conjugate qˉ=(w,v)\bar q=(w,-\mathbf v)
Is the product of two unit quaternions a unit quaternion
Yes, pq=pq|pq|=|p||q|

Concept Map

scalar plus vector

imply

cyclic right-handed

substituted into

multiplied via

collect scalar

collect vector

combine

combine

cross product term

represents

used in

Quaternion w plus xi yj zk

Scalar w and vector v

Hamilton rules i2 j2 k2 ijk eq -1

Multiplication table ij eq k etc

Right-handed frame axes

Distribute 16 products

Scalar part w1w2 minus v1 dot v2

Vector part w1v2 plus w2v1 plus cross

Hamilton product

Non-commutative pq ne qp

Composed 3D rotation

Attitude filter MEKF gyro integration

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, quaternion ek chhota sa 4-number ka packet hai jo ek rotation ko store karta hai: ek scalar part ww aur ek vector part (x,y,z)(x,y,z). Jab aap do rotations ko ek ke baad ek lagate ho, to unko combine karne ka rule hi Hamilton product hai. Yeh basically rotation matrices ko multiply karne jaisa hai, but sirf 4 numbers ke saath, koi bhaari trigonometry nahi.

Formula ka core simple hai agar aap scalar+vector notation mein soch lo: scalar part ban-ta hai w1w2v1v2w_1w_2 - \mathbf v_1\cdot\mathbf v_2 (dot product wala minus), aur vector part ban-ta hai w1v2+w2v1+v1×v2w_1\mathbf v_2 + w_2\mathbf v_1 + \mathbf v_1\times\mathbf v_2. Yeh koi rata-fied formula nahi hai — bas i,j,ki,j,k ke rules (ij=kij=k, ji=kji=-k, ijk=1ijk=-1) laga ke distribute karo, sab ingredients apne aap aa jaate hain. Sabse important cheez: sirf cross product term hi non-symmetric hai, isiliye pqqppq \ne qp — matlab pehle A phir B, aur pehle B phir A, dono alag results dete hain. Yeh natural hai kyunki 3D mein rotations sach mein commute nahi karte (Rubik's cube ki tarah).

GNC mein iska matlab bahut bada hai: drone ya satellite ka attitude filter har millisecond gyro ka data lekar ek tiny quaternion multiply karta hai. Agar aap order ulta kar do ya normalize karna bhool jao, to orientation drift ya flip ho jaayega. Convention: qtotal=qlastqfirstq_{\text{total}} = q_{\text{last}}\, q_{\text{first}}, yaad rakho — right se left. Aur vector ko rotate karne ke liye sandwich formula quqˉq\,u\,\bar q use hota hai, jisme half-angle θ/2\theta/2 isiliye aata hai kyunki rotation do baar half apply hota hai. Bas yeh clear ho gaya to poora quaternion attitude control aapka.

Go deeper — visual, from zero

Test yourself — Guidance, Navigation & Control (GNC)

Connections