Leture 3: orienttion Computer Animtion
Mop tutoril sessions Next Thursdy (Feb ) Tem distribution: : - :3 - Tems 7, 8, 9 :3 - : - Tems nd : - :3 - Tems 5 nd 6 :3 - : - Tems 3 nd 4
Pper ssignments Pper ssignment on the website Mop tems + ppers in one PDF Tems of (exept for pper 3)
Questions Any uestions bout lst leture?
Orienttion We will define orienttion to men n objet s instntneous rottionl onfigurtion Think of it s the rottionl euivlent of position
Representing Positions Crtesin oordintes (x,y,z) re n esy nd nturl mens of representing position in 3D spe There re mny other lterntives suh s polr nottion (r,θ,φ) nd you n invent others if you wnt to
Representing Orienttions Is there simple mens of representing 3D orienttion? (nlogous to Crtesin oordintes?) Not relly. There re severl populr options though: Euler ngles Rottion vetors (xis/ngle) 3x3 mtries Quternions nd more
Euler s Theorem Euler s Theorem: Any two independent orthonorml oordinte frmes n be relted by seuene of rottions (not more thn three) bout oordinte xes, where no two suessive rottions my be bout the sme xis. Leonrd Euler (77-783)
Euler Angles This mens tht we n represent n orienttion with 3 numbers A seuene of rottions round prinipl xes is lled n Euler Angle Seuene Assuming we limit ourselves to 3 rottions without suessive rottions bout the sme xis, we ould use ny of the following seuenes: XYZ XZY XYX XZX YXZ YZX YXY YZY ZXY ZYX ZXZ ZYZ
Euler Angles This gives us redundnt wys to store n orienttion using Euler ngles Different industries use different onventions for hndling Euler ngles (or no onventions)
Euler Angles to Mtrix Conversion To build mtrix from set of Euler ngles, we just multiply seuene of rottion mtries together: y x z x z y x z x z y x y x z x z y x z x z y x y z y z y s s s s s s s s s s s s s s s z z z z y y y y x x x x z y x s s s s s s R R R
Euler Angle Order As mtrix multiplition is not ommuttive, the order of opertions is importnt Rottions re ssumed to be reltive to fixed world xes, rther thn lol to the objet One n think of them s being lol to the objet if the seuene order is reversed
Using Euler Angles To use Euler ngles, one must hoose whih of the representtions they wnt There my be some prtil differenes between them nd the best seuene my depend on wht extly you re trying to omplish
Vehile Orienttion Generlly, for vehiles, it is most onvenient to rotte in roll (z), pith (x), nd then yw (y) In situtions where there is definite ground plne, Euler ngles n tully be n intuitive representtion Imge soure: Smithsonin Ntionl Air nd Spe Museum
Gimbl Lok One potentil problem tht they n suffer from is gimbl lok This results when two xes effetively line up, resulting in temporry loss of degree of freedom This is relted to the singulrities in longitude tht you get t the north nd south poles
Interpolting Euler Angles One n simply interpolte between the three vlues independently This will result in the interpoltion following different pth depending on whih of the shemes you hoose This my or my not be problem, depending on your sitution Interpolting ner the poles n be problemti Note: when interpolting ngles, remember to hek for rossing the +8/-8 degree boundries
Euler Angles Euler ngles re used in lot of pplitions, but they tend to reuire some rther rbitrry deisions They lso do not interpolte in onsistent wy (but this isn t lwys bd) They n suffer from Gimbl lok nd relted problems There is no simple wy to ontente rottions Conversion to/from mtrix reuires severl trigonometry opertions They re ompt (reuiring only 3 numbers)
Rottion Vetors nd Axis/Angle Euler lso showed tht ny two orienttions n be relted by single rottion bout some xis (not neessrily prinipl xis) This mens tht we n represent n rbitrry orienttion s rottion bout some unit xis by some ngle (4 numbers) (Axis/Angle form) Alterntely, we n sle the xis by the ngle nd ompt it down to single 3D vetor rottion vetor or exponentil mp
Axis/Angle to Mtrix To generte mtrix s rottion θ round n rbitrry unit xis : ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( z z x z y y z x x z y y y z y x y z x z y x x x s s s s s s
Rottion Vetors To onvert the exponentil mp to mtrix, one needs to extrt the mgnitude nd then rotte round the normlized xis Normlly, rottion vetor formt is more useful for representing ngulr veloities nd ngulr elertions, rther thn ngulr position (orienttion) Also used for interpolting > orienttions
Axis/Angle Representtion Storing n orienttion s n xis nd n ngle uses 4 numbers, but Euler s theorem sys tht we only need 3 numbers to represent n orienttion Mthemtilly, this mens tht we re using 4 degrees of freedom to represent 3 degrees of freedom vlue This implies tht there is possibly extr or redundnt informtion in the xis/ngle formt The redundny mnifests itself in the mgnitude of the xis vetor. The mgnitude rries no informtion, nd so it is redundnt. To remove the redundny, we hoose to normlize the xis, thus onstrining the extr degree of freedom
Mtrix Representtion We n use 3x3 mtrix to represent n orienttion s well This mens we now hve 9 numbers insted of 3, nd therefore, we hve 6 extr degrees of freedom NOTE: We don t use 4x4 mtries here, s those re minly useful beuse they give us the bility to ombine trnsltions. We will not be onerned with trnsltion tody, so we will just onsider 3x3 mtries.
Mtrix Representtion Those extr 6 DOFs mnifest themselves s 3 sles (x, y, nd z) nd 3 shers (xy, xz, nd yz) If we ssume the mtrix represents rigid trnsform (orthonorml), then we n onstrin the extr 6 DOFs b b b b
Mtrix Representtion Mtries re usully the most omputtionlly effiient wy to pply rottions to geometri dt, nd so most orienttion representtions ultimtely need to be onverted into mtrix in order to do nything useful (trnsform verts ) Why then, shouldn t we just lwys use mtries? Numeril issues Storge issues User intertion issues Interpoltion issues
Quternions
Quternions Quternions re n interesting mthemtil onept with deep reltionship with the foundtions of lgebr nd number theory Invented by W.R.Hmilton in 843 In prtie, they re most useful to us s mens of representing orienttions A uternion hs 4 omponents 3
Quternions (Imginry Spe) Quternions re tully n extension to omplex numbers Of the 4 omponents, one is rel slr number, nd the other 3 form vetor in imginry ijk spe! i j k3 i j k ijk i jk kj j ki ik k ij ji
Quternions (Slr/Vetor) Sometimes, they re written s the ombintion of slr vlue s nd vetor vlue v s, v where s v 3
Unit Quternions For onveniene, we will use only unit length uternions, s they will be suffiient for our purposes nd mke things little esier 3 These orrespond to the set of vetors tht form the surfe of 4D hypersphere of rdius The surfe is tully 3D volume in 4D spe, but it n be visulized s n extension to the onept of D surfe on 3D sphere
Quternions s Rottions A uternion n represent rottion by n ngle θ round unit xis : or os x sin os, sin sin If is unit length, then will be lso y z sin
Quternions s Rottions sin os sin os sin os sin sin sin os 3 z y x z y x
Quternion to Mtrix To onvert uternion to rottion mtrix: 3 3 3 3 3 3 3 3
Mtrix to Quternion Mtrix to uternion is not too bd, I just don t hve room for it here It involves few if sttements, sure root, three divisions, nd some other stuff For the lgorithm, see: http://www.eulidenspe.om/mths/geometry/rottions/ onversions/mtrixtoquternion/index.htm
Spheres Think of person stnding on the surfe of big sphere (like plnet) From the person s point of view, they n move in long two orthogonl xes (front/bk) nd (left/right) There is no pereption of ny fixed poles or longitude/ltitude, beuse no mtter whih diretion they fe, they lwys hve two orthogonl wys to go From their point of view, they might s well be moving on infinite D plne, however if they go too fr in one diretion, they will ome bk to where they strted!
Hyperspheres Now extend this onept to moving in the hypersphere of unit uternions The person now hs three orthogonl diretions to go No mtter how they re oriented in this spe, they n lwys go some ombintion of forwrd/bkwrd, left/right nd up/down If they go too fr in ny one diretion, they will ome bk to where they strted
Hyperspheres Now onsider tht person s lotion on this hypersphere represents n orienttion Any inrementl movement long one of the orthogonl xes in urved spe orresponds to n inrementl rottion long n xis in rel spe (distnes long the hypersphere orrespond to ngles in 3D spe) Moving in some rbitrry diretion orresponds to rotting round some rbitrry xis If you move too fr in one diretion, you ome bk to where you strted (orresponding to rotting 36 degrees round ny one xis)
Hyperspheres A distne of x long the surfe of the hypersphere orresponds to rottion of ngle x rdins This mens tht moving long 9 degree r on the hypersphere orresponds to rotting n objet by 8 degrees Trveling 8 degrees orresponds to 36 degree rottion, thus getting you bk to where you strted This implies tht nd - orrespond to the sme orienttion
Hyperspheres Consider wht would hppen if this ws not the se, nd if 8 degrees long the hypersphere orresponded to 8 degree rottion This would men tht there is extly one orienttion tht is 8 opposite to referene orienttion In relity, there is ontinuum of possible orienttions tht re 8 wy from referene They n be found on the eutor reltive to ny point on the hypersphere
Hyperspheres Also onsider wht hppens if you rotte book 8 round x, then 8 round y, nd then 8 round z You end up bk where you strted This orresponds to trveling long tringle on the hypersphere where eh edge is 9 degree r, orthogonl to eh other edge
Hyperspheres Soure: https://www.youtube.om/wth?v=o_w8r_jt8 Top resons why we know the erth is round
Quternion Dot Produts The dot produt of two uternions works in the sme wy s the dot produt of two vetors: p p p p p33 p os The ngle between two uternions in 4D spe is hlf the ngle one would need to rotte from one orienttion to the other in 3D spe
Quternion Multiplition Note tht two unit uternions multiplied together will result in nother unit uternion This orresponds to the sme property of omplex numbers Remember tht multiplition by omplex numbers n be thought of s rottion in the omplex plne Quternions extend the plnr rottions of omplex numbers to 3D rottions in spe
Quternion Joints One n rete skeleton using uternion joints One possibility is to simply llow uternion joint type nd provide lol mtrix funtion tht tkes uternion Another possibility is to lso ompute the world mtries s uternion multiplitions. This involves little less mth thn mtries, but my not prove to be signifintly fster. Also, one would still hve to hndle the joint offsets with mtrix mth
Quternions in the Pose Vetor Using uternions in the skeleton dds some omplitions, s they n t simply be treted s 4 independent DOFs through the rig The reson is tht the 4 numbers re not independent, nd so n nimtion system would hve to hndle them speifilly s uternion To del with this, one might hve to extend the onept of the pose vetor s ontining n rry of slrs nd n rry of uternions When higher level nimtion ode blends nd mnipultes poses, it will hve to tret uternions speilly
Quternion Interpoltion
Liner Interpoltion If we wnt to do liner interpoltion between two points nd b in norml spe Lerp(t,,b) = (-t) + (t)b where t rnges from to Note tht the Lerp opertion n be thought of s weighted verge (onvex) We ould lso write it in it s dditive blend form: Lerp(t,,b) = + t(b-)
Spheril Liner Interpoltion If we wnt to interpolte between two points on sphere (or hypersphere), we don t just wnt to Lerp between them Insted, we will trvel ross the surfe of the sphere by following gret r
Spheril Liner Interpoltion We define the spheril liner interpoltion of two unit vetors in N dimensionl spe s: Slerp( t,, b) t sint sin sin sin b where : os b
Quternion Interpoltion Remember tht there re two redundnt vetors in uternion spe for every uniue orienttion in 3D spe Wht is the differene between: Slerp(t,,b) nd Slerp(t,,-b)? One of these will trvel less thn 9 degrees while the other will trvel more thn 9 degrees ross the sphere This orresponds to rotting the short wy or the long wy Usully, we wnt to tke the short wy, so we negte one of them if their dot produt is <
Bezier Curves in D & 3D Spe Bezier urves n be thought of s higher order extension of liner interpoltion p p p p p 3 p p p p
de Cstleju Algorithm p Find the point x on the urve s funtion of prmeter t: p p p 3
de Cstleju Algorithm p Lerp Lerp Lerp t, p t, p t, p, p, p, p 3 p p p 3
de Cstleju Algorithm r r r Lerp Lerp t, t,,, r
de Cstleju Algorithm x Lerp t, r r, r x r
de Cstleju Algorithm x Animted + more info t http://pomx.github.io/bezierinfo/#destelju
de Cstleju Algorithm 3,,,,,, p p p p p p t Lerp t Lerp t Lerp,,,, r r t Lerp t Lerp,, r r x t Lerp 3 p p p p Just points, not uternions
Bezier Curves in Quternion Spe We n onstrut Bezier urves on the 4D hypersphere by following the ext sme proedure using Slerp insted of Lerp It s good ide to flip (negte) the input uternions s neessry in order to mke it go the short wy There re other, more sophistited urve interpoltion lgorithms tht n be pplied to hypersphere Interpolte severl key poses Additionl ontrol over ngulr veloity, ngulr elertion, smoothness
Quternion Summry Quternions re 4D vetors tht n represent 3D rigid body orienttions We hoose to fore them to be unit length Key nimtion funtions: Quternion-to-mtrix / mtrix-to-uternion Quternion multiplition: fster thn mtrix multiplition Slerp: interpolte between rbitrry orienttions Spheril urves: de Cstleju lgorithm for ubi Bezier urves on the hypersphere
Quternion Referenes Animting Rottion with Quternion Curves, Ken Shoemke, SIGGRAPH 985 Quternions nd Rottion Seuenes: A Primer with Applitions to Orbits, Aerospe nd Virtul Relity, Jk B. Kuipers,