You are on page 1of 4

10.12.

2014

7Quaternions

7.1Introduction
WilliamRowanHamilton'sdiscoveryofquaternionsonanOctobermorningin1843isoneofthebest
documentedscientificeventsinhistory."Quaternionssprangtolight,orlife,fullgrown,"wrote
Hamiltoninhismemoirs.Hewas"walkingwithLadyHamiltonoverBroughamBridge",nowknown
locallyasQuaternionBridge,inDublin.LadyHamiltonwastalkingtoherhusband,relatingsome
privatethoughtsofdeeppersonalsignificancewhen"Suddenlythegalvaniccircuitofthoughtclosed,and
thebasicquaternionequationspresentedthemselvestomymind,exactlyasIhaveusedthemeversince."
Attheendofthelastchapterquaternionswereintroducedtoyouassumsofscalarsandbivectorsin3D
space.ThisisnothowHamiltondefinedthemin1843,onegoodreasonbeingthatnobodyknewabout
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
correctformulaforrotatingvectors).Quaternionsforma4Dvectorspacewithadditionandscalar
multiplicationdefinedintheobviousway.Vectorsin3Dspacecanberegardedasquaternionswiththe
scalarcomponentq0=0ifyouremovethescalarcomponentofaquaternionq,what'sleftiscalledthe
vectorpartofq,andiswritteneitherVqorq(boldface).
Inadditiontotheusualvectorspaceoperations,thereisanoncommutative,bilinear,associative
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
I.Theconjugationoperation,qvq1,rotatesthevectorvabouttheaxisofq(accordingtotherighthand
rule)throughtwicetheangleofq.Thisholdsforany(3component)vectorvandanynonzero
quaternionq,thoughwe'llalmostalwaysuseunitquaternionsinourcalculations.
Example7.1.Ifyouwanttorotatethevectorv=(1,2,0)=i+2j60rightwardaboutaverticalaxis
(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+
1.08j+.62jk=2.25i+.14j=(2.25,.14,0).Youcandrawapicturetoverifythatthisansweriscorrect,
butnotealsothatthereareanumberofquickchecksyoucandotoseethattheresultmakessense:1.The
productqvq1isa3componentvector(i.e.thescalarcomponentis0),2.Thevectorsvandqvq1have
thesameverticalcomponent,asyouwouldexpectforarotationaboutaverticalaxis,and3.Youcansee
thatthemagnitudeofqvq1isthesameasthatofv.
Problem7.1.Usequaternionstorotatethevectorj90upandtorotatethevector(4,0,1)40leftand
clockwiseaboutanaxistilted30forwardfromkintheikplane.
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
usuallyusetheunitquaternionwiththescalarcomponentq0>0.Whenwetalkaboutthequaternionof
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
wecomposetherotationsusingquaternions,weobtaintheproductijk=kk=1,insteadof1.This
answeriscorrect,becauseboth1and1representthenullrotation.
Problem7.2.Supposeanexperimentalsubjectislookingstraightahead,i.e.g=i.a.Computethegaze
vectorandthequaternionofthesubject'seyepositionaftertworotations,30leftand20down.b.Do
thesameforthesamerotationsintheoppositeorder.c.Dothesamefortheeyepositionattainedby
rotatingfirst30leftandthen20upaboutanaxisorthogonaltothegazeline(whichisdirected30left
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

rotationof20downaboutanaxisrotated30leftfromj.
Itwillbeveryusefultoconsiderasimpleexampleofthisprincipleinpreparationforthemore
complicatedapplicationsinthenextsection.We'llusethequaternionsrandqdefinedaboveandapply
Formula(7.8)toProblem7.2.Inparta,youwereaskedtocomputethefinaleyepositionaftertwoeye
rotations:30leftfollowedby20down.Sincequaternionrrepresentsthefirstrotationandqthesecond,
theoverallrotationinpartaisqr.Inpartb,theorderisreversed,givingrq.Inpartc,thefirstrotationisr
andthesecondisarotation,callitp,of20downaboutanaxistilted30left.Youcaneitherworkout
thisquaternionfromscratch:p=cos10+sin10(.5,.87,0),oryoucanobservethatp=rqr1,andsothe
overallrotationispr=rqr1r=rqi.e.therotationisthesameasinpartb.Ihavedescribedthisas
"changingthecoordinatesystem"ofarotationbecauseqisaverticalrotationinheadorspace
coordinateswhilep=rqr1isaverticalrotationineyecoordinates.Youshouldthinkaboutthisexample
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
QP8.qxrotatesxtimesasfarasqaboutthesameaxis
QP9.rqr1rotatestherotationaxisofq

http://tutis.ca/Rotate/7quaternions.htm

4/4