You are on page 1of 4

# 10.12.

2014

7Quaternions

7.1Introduction
WilliamRowanHamilton'sdiscoveryofquaternionsonanOctobermorningin1843isoneofthebest
documentedscientificeventsinhistory."Quaternionssprangtolight,orlife,fullgrown,"wrote
privatethoughtsofdeeppersonalsignificancewhen"Suddenlythegalvaniccircuitofthoughtclosed,and
thebasicquaternionequationspresentedthemselvestomymind,exactlyasIhaveusedthemeversince."
Attheendofthelastchapterquaternionswereintroducedtoyouassumsofscalarsandbivectorsin3D
bivectorsthen.Eventoday,quaternionsareusuallypresentedasanisolatedalgebraicsystem,
disconnectedfromgenerallinearalgebra,andrestrictedintheirapplicationto3Dspace.Inthischapter
wetoowilltreatquaternionsasanisolatedsystemforcalculating3Drotations.Thiswayyoucangetthe
mainpointsofquaternionalgebrainonechapterwithoutbeingoverwhelmedbyhugebizarrespacesof
bivectorsandotherexoticawhicharelessdirectlyrelevanttoyourwork.
7.2Definitions
Indiscussingquaternionsweusethenamesi,jandkforthestandard(righthanded,orthonormal)basis
vectors.Weforgetthatweeverdreamedofbivectors,andregardaquaternionasthesumofascalarand
avector:
q=q0+q1i+q2j+q3k.(7.1)
(Sincevectorsandbivectorsin3Dspacearesosimilarintheirproperties,westillendupwiththe
multiplicationdefinedintheobviousway.Vectorsin3Dspacecanberegardedasquaternionswiththe
scalarcomponentq0=0ifyouremovethescalarcomponentofaquaternionq,what'sleftiscalledthe
vectorpartofq,andiswritteneitherVqorq(boldface).
operationcalledquaternionmultiplication(reallyaspecialcaseofCliffordmultiplication)whichis
definedbytherules:
i2=j2=k2=1(7.2)
ij=ji=kjk=kj=iki=ik=j
ThesearethebasicquaternionequationswhichsprangintoHamilton'smindfullgrown,andwhichhe
immediatelycarvedwithapenknifeintothestoneofBroughamBridge.Theeasiestwaytoremember
theserulesistowritei,jandkaroundacircleaswedidforthecrossproductinChapter2.Harderto
remember,butfasterforhandcomputation,isthefollowingformulafortheproductr=pq,withcanbe
derivedfrom(7.2):
r0=p0q0p1q1p2q2p3q3
r1=p0q1+p1q0+p2q3p3q2
r2=p0q2+p2q0p1q3+p3q1
r3=p0q3+p3q0+p1q2p2q1.(7.3)
http://tutis.ca/Rotate/7quaternions.htm

1/4

10.12.2014

7Quaternions

Themagnitudeofaquaternionis|q|=(q02+q12+q22+q32).5.Everynonzeroquaternionhasaunique
inverseq1suchthatqq1=q1q=1.Itisnothardtoverifythattheinverseofqis
q1=(q0q1q2q3)/|q|2=(q0q)/|q|2(7.4)
Inparticular,fortheunitquaternionswhichwewillmainlybeusing:
q1=q0q(7.5)
Finally,twodefinitionswillpavethewayfortheapplicationofquaternionstorotations.Wenotethata
unitquaternioncanalwaysbewrittenintheform
cos+n1sin+n2sin+n3sin.(7.6)
wheren=(n1,n2,n3)isaunitvector.Proof:Themagnitudeofthevectorpartofthequaternion,q,must
bebetween1and1(inclusive),andsotheremustbesomeangle,suchthat|q|=sin.Thusqcanbe
writtenq=|q|n=sinn,wherenisqnormalized.Thesumofsquaresofthequaternioncomponents
mustbe|q|=1,andsoq02=1|q|2=1sin2=cos2.|||Hereniscalledtheaxis,theangle,ofthe
quaternion.Anonunitquaternionalsohasanangleandaxis,whichareobtainedbynormalizingitand
computingtheangleandaxisoftheresultingunitquaternion.
7.3QuaternionsandRotations
rule)throughtwicetheangleofq.Thisholdsforany(3component)vectorvandanynonzero
quaternionq,thoughwe'llalmostalwaysuseunitquaternionsinourcalculations.
(parallelwithk),youfirstconstructtherelevantunitquaternion.Theaxisnofthequaternionmustbe
vertical,andmustpointdowninordertorepresentarightwardrotationbytherighthandrule(because
whenyoupointyourrightthumbdown,yourfingerscurlroundtotheright)thusn=k=(0,0,1).The
angleofthequaternionmustbehalfthedesiredrotationangle,ie=60/2=30.Thescalarpartof
thequaternion,q0,isthereforecos=cos30=.87.Thevectorpart,q,issinn=.5n=(0,0,.5).The
quaternionasawholecanthenbewritten(.87,0,0,.5)or.87.5k.Therotatedvectorisqvq1=(.87
.5k)(i+2j)(.87+.5k)=(.87i+1.74j.5kikj)(.87+.5k)=(1.87i+1.24j)(.87+.5k)=1.63i+.94ik+
butnotealsothatthereareanumberofquickchecksyoucandotoseethattheresultmakessense:1.The
productqvq1isa3componentvector(i.e.thescalarcomponentis0),2.Thevectorsvandqvq1have
thatthemagnitudeofqvq1isthesameasthatofv.
Problem7.1.Usequaternionstorotatethevectorj90upandtorotatethevector(4,0,1)40leftand
Apeculiarfeatureofquaternionsisthatinfinitelymanyofthemcorrespondtoanygivenrotation.Tosee
this,wemustfirstobservethat,ifsisanynonzeroscalarandqanynonzeroquaternion,then(sq)1=q1
/s,because(sq)(q1/s)=s(qq1)/s=s/s=1.Nowwecanprovethat,ifqisanonzeroquaternion
representingsomerotation,thenanynonzeroscalarmultiplesqrepresentsthesamerotation,because
http://tutis.ca/Rotate/7quaternions.htm

2/4

10.12.2014

7Quaternions

(sq)v(sq)1=(sq)v(q1)/s=s(qvq1)/s=qvq1.Inotherwords,allnonzeroscalarmultiplesofany
quaternionrepresentthesamerotation.Oftheinfinityofquaternionsrepresentinganyrotation,twowill
beunitquaternions(givenone,yougettheothermymultiplyingby1).Forourcomputations,we
eyeposition,wewillalwaysmeantheunitquaternionwithanonnegativescalarcomponent.
II.Quaternionmultiplicationcanbeusedtocomposerotations.Ifquaternionsq'andq''represent
rotationsR1andR2respectively,thenthequaternionproductq''q'representsthecompositionR2R1.
Notethatthequaternionrepresentingthesecondrotationisontheleftsideintheproduct.Ifyoumixup
theorder,youwillgetthewrongcompositerotation,thankstononcommutativity.
Example7.2.Thethreerotations,180clockwise,180downand180leftarerepresentedbythe
quaternionsi,jandk.Thecompositeofallthreerotationsinthisorderiskji=ii=1=(1,0,0,0),
whichhasscalarcomponent1andthereforeangle=arccos(1)=0.Thatis,thecompositeofthesethree
isthenullrotation,asyoucaneasilyverify.Notethatifyoucomposethethreerotations180left,180
downand180clockwiseinthisorder,youagaingetthenullrotation(checkthiswithateddybear).If
vectorandthequaternionofthesubject'seyepositionaftertworotations,30leftand20down.b.Do
thesameforthesamerotationsintheoppositeorder.c.Dothesamefortheeyepositionattainedby
afterthefirstrotation).
III.Quaternionpowerscanbeusedtoiterateor"divide"rotations.Forexample,ifqrepresentsa
rotationof20right,thenq2representsarotationof40rightandq1/2(thesquarerootofq)representsa
rotationof10right.Tocomputeapower,weexpressthequaternionintermsofitsaxisandangle:ifq=
|q|(cos+nsin)then
qx=|q|x[cos(x)+nsin(x)].(7.7)
Notethatifx=1,thisequationreducestoFormula(7.4)forquaternioninversion.Notealsothatall
powersofagivenquaternionhavethesameaxis(n)andthatallpowersofaunitquaternionarealsounit
quaternions.
IV.Quaternionconjugationcanbeusedtochangethecoordinatesystemofarotation.Thisvery
importantapplicationrecursthroughoutourwork.Forexample,supposerisaquaternionrepresentinga
rotationof30left,andqrepresentsarotationof20down(sothatthevectorpartofqisjsin10).
Observewhathappenswhenweconjugateqwithr:
rqr1=r(q0+q)r1
=rq0r1+rqr1
=q0rr1+rqr1
=q0+rqr1.(7.8)
Whathappensisthatthescalarcomponentq0isunchanged,whilethevectorpartgetsrotated30left.It
followsthattheangleofthequaternionisunchanged,buttheaxisrotates,sothatrqr1representsa
http://tutis.ca/Rotate/7quaternions.htm

3/4

10.12.2014

7Quaternions

Itwillbeveryusefultoconsiderasimpleexampleofthisprincipleinpreparationforthemore
complicatedapplicationsinthenextsection.We'llusethequaternionsrandqdefinedaboveandapply
rotations:30leftfollowedby20down.Sincequaternionrrepresentsthefirstrotationandqthesecond,
theoverallrotationinpartaisqr.Inpartb,theorderisreversed,givingrq.Inpartc,thefirstrotationisr
thisquaternionfromscratch:p=cos10+sin10(.5,.87,0),oryoucanobservethatp=rqr1,andsothe
overallrotationispr=rqr1r=rqi.e.therotationisthesameasinpartb.Ihavedescribedthisas
constantly,fordaysonendifnecessary,untilthegalvaniccircuitofthoughtclosesandtheequationsand
theirphysicalmeaningareclear.
Themainpropertiesofquaternionsaresummarizedinthelistbelow:
QP1.pqisnotequaltoqp
QP2.p(q+r)=pq+pr
QP3.(sp)q=p(sq)=s(pq)
QP4.q1=(q0q)/|q|2
QP5.p(qr)=(pq)r
QP6.qvq1rotatesavector
QP7.pqcomposestworotations