4/7/9 D Tansfomations Wh Tansfomations Coodinate sstem tansfomations Placing objects in the wold Move/animate the camea fo navigation Dawing hieachical chaactes Animation Tanslation + d 5,4 + d,3 d 4, 6, T P P d, 3, P P + T tanslation (3,) 3
4/7/9 Rotation P(,) P (, ) 4 ) ( ) ( + + ) ( ) ( + ϕ + + Rotation, 3,,3 5, + R P RP P Scale s s 4,6 ss 6, 3,,3 P P s s S P SP 6,,
4/7/9 Efficienc Poblem... Tanslation is pefomed with an addition, while scale and otation ae pefomed with multiplication. We d like to teat them all the same to avoid eta bookkeeping! optimize the hadwae compose tansfomations P T + P P SP P RP 7 Homogenous Coodinates Teat tanslation as a multiplication Requies an eta coodinate / w Homogenous Point, w / w Catesian Point, Use w and the homogenous point catesian point Use w to epesent a homogenous diection vecto 8 Homogenous Coodinates Mathematical model: Pojective planes Eve line pasg though the oigin is a point in the pojective plane Can be seen as points in the set w plus lines puel inside w Anothe epesentation is to identif antipodal points inside N-dimensional sphee Non-oientable ecept when N Mobius band + disk Possible issue: *futue is in the past* 9 3
4/7/9 Homogenous Coodinates d c s T d R s c s S s I Which one does NOT affect a vecto? Composition Seies of tansfomations can be composited into a gle tansfomation mati Fo eample, how do we otate aound a point othe than the oigin? a,b How do we otate about this point? Composition Appl a seies of tansfomations tanslate to the oigin otate tanslate back a,b a,b 4
4/7/9 Composition a,b a,b tanslate(-a,-b) otate(9) tanslate(a,b) T a b R T a b T RT P P 3 Composition Eample tanslate b in scale b in, (unifom scaling) T S,3,3,3,3 -,, 3,, 3, 4 Composition Eample # Tanslate, Scale (,) (-,) (-,) (3,) (,) (,) (,3) tanslate (,3) scale (,6) # Scale, Tanslate (,) (,) (,) (3,) (6,) (4,) (,3) scale (4,6) tanslate (,6) 5 5
4/7/9 6 Composition Eample P STP 4 osuscale(.,.); osutanslate(-.,.); dawtiangle(); 6 P TSP osutanslate(-.,.); osuscale(.,.); dawtiangle(); Mati multiplication is not commutative!!! So the ode of appling the tansfomations is impotant. Composition Thee ae two was to think about tansfomations In a gand, fied coodinate sstem In a moving coodinate sstem D di h i li 7 Depending on how ou visualize ou tansfomations, ou must pefom ou multiplications in a specific ode ight to left w..t. gand fied sstem left to ight w..t. moving coodinate sstem Composition 8 a a
4/7/9 Gand Fied Coodinate Sstem Rotate Tanslate a a Absolute tansfomation. Eecute the tansfoms Right to Left w..t. efeence fame P TRP 9 Moving Coodinate Sstem Tanslate Rotate a Relative tansfomation. Left to ight w..t. the new moving coodinate sstem P TRP Absolute vs. Relative Results ae the same Useful to think in tems of elative when building a hieachical chaacte Think in tems of the sstem that makes the most sense appl tansfoms in the coect ode also applies to gaphics liba outines 7
4/7/9 OpenGL/osuGL P TRP Eithe wa I think about the tansfomation, this is m esult! osutanslate(); osurotate(); dawpoint(); In ou gaphics liba, list the tansfoms in the ode that the appea when eading the tansfomation equation! 3D Tansfomations 3 3D Coodinate Sstem +z + Homogenous 3D point + z w z Catesian 3D point Homogenous 3D point when w 4 8
4/7/9 Tanslation and Scale Tanslation t t tz Scale s s sz 5 3D Rotation Now, have 3 aes we can otate about Rotate Notice, does not change Looking down negative otating counte clockwise 6 3D Rotations Rotate RotateZ Invese of 3D otation is it s tanspose! 7 9
4/7/9 3D Rotations Quatenion W+i+j+Zk i*ij*jk*k- i*jk, j*ki, k*ij j*i-k, k*j-i, i*k-j 8 3D Rotations Unit quatenion coesponds to 3D otations: W*W+*+*+Z*Z W(t/), (,,Z)(t/)(,,z) (,, z) is a unit vecto along the ais of otation t is the angle of otation 9 3D Rotations To otate a vecto vai+bj+ck aound the ais (,, z) b an angle of t q (t/) + (t/)(i+j+zk) p (t/) - (t/)(i+j+zk) v q*v*p 3
4/7/9 Wh use tansfomations? Placement of objects Re-ug o instancing objects Hieachical tansfomations Changes in coodinate sstems 3 Mati Stacks Immediate mode gaphics commands ae eecuted as encounteed Retained mode gaphics commands ae stoed in a data stuctue and eecuted at some time in the pipeline 3 Mati Stack Teminolog Teminolog CTM : cuent tansfomation mati osupushmati : duplicate the CTM and put on top of the stack emembe whee ou ae osupopmati: pop the top tansfomation off of the stack osutanslate osurotate osuscale The CTM affects an vete (osuvetef) 33
4/7/9 Hieachical Chaacte Model Chaactes ae tee like Have a oot and limbs Good place to use the mati stack to facilitate the modeling 34 Hieachical Robot push s pop toso t am Robot t,s am t hand hand,s,t,s,t thumb finge thumb finge 35 void squae(){ begin(polgon); vete(-,-); vete(-,); vete(,); vete(,-); end(); } Hieachical Chaacte 36
4/7/9 Mati Stacks Often useful to be able to save and ecall the cuent tansfomation Hieachical models Instancing 37 Cuent Tansfomation Mati (CTM) Conceptuall thee is a 4 4 homogeneous coodinate mati, the cuent tansfomation mati (CTM) that is pat of the state and is applied to all vetices that pass down the pipeline The CTM is defined in the use pogam and loaded into a tansfomation unit vetices p C CTM p Cp vetices 38 CTM opeations The CTM can be alteed eithe b loading a new CTM o b postmutiplication Load an identit mati: C I Load an abita mati: C M Load a tanslation mati: C T Load a otation mati: C R Load a scaling mati: C S Postmultipl b an abita mati: C CM Postmultipl b a tanslation mati: C CT Postmultipl b a otation mati: C CR Postmultipl b a scaling mati: C CS 39 3
4/7/9 CTM Opeations Push Mati Makes a cop and stoes it on the top of the stack Pop Mati Pops the top of the mati stack Mati Stack is init. to CTM I 4 4