Uses of trnsformtions 3D trnsformtions Modeling: position nd resize prts of complex model; Viewing: define nd position the virtul cmer Animtion: define how objects move/chnge with time y y Sclr (dot) product ( number): α b Cross product ( vector): x x Review of vectors Addition: +b Multipliction by number c: 3D: D E 2D: 3D: b (,b) = x b x + y b y c (,b) = x b x + y b y + z b z (,b) = b cosα (,b) = (b,) (, k 1 b +k 2 c ) = k 1 (,b)+k 2 (,c ) GHW H[ H\ H] D [ D \ D ] E [ E \ E ] MD EM MDMMEM VLQ D E ƒe D Vectors in 3D p y p p x p z S S [ H [ H \ H ] unit bsis vectors D N E NF ND E ND F Homogeneous coordintes S [ % S [ S Z & % regulr 3D point to homogeneous: homogeneous point to regulr 3D: & S [ S Z S Z S Z Points vs. vectors trnslted point is different point trnslted vector is the sme vector in homogeneous coordintes: points hve lst component nonzero vectors hve lst component zero 1
Trnsltion nd scling Similr to 2D; trnsltion by vector W >W [ W \ W ] @ Nonuniform scling in three directions W [ W \ W ] V [ V \ V ] Rottions round coord xes ngle, round X xis: round Y xis: FRV ƒ VLQ VLQ FRV round Z xis: FRV ƒ VLQ VLQ FRV FRV VLQ ƒ VLQ FRV note where the minus is! Generl rottions Given n xis ( unit vector) nd n ngle, find the mtrix S N Y S S" S N rotted S rotted S" S" Only the component perpendiculr to xis chnges Y Generl rottions (rotted vectors re denoted with ) project p on Y: the rest of p is the other component: rotte perp. component: dd bck two components: S Combine everything, using S N SYY S" S ƒ SYY S " S" FRV D Y S" VLQ S " S N Y S" Y S to simplify: S FRV S ƒ FRV SYY VLQ Y S Generl rottions Composition of trnsformtions How do we write ll this using mtrices? SYY Y S S FRV S ƒ FRV SYY VLQ Y S Y[Y[ Y[Y\S\ Y[Y]S] Y[Y[ Y[Y\ Y[Y] Y\Y[ Y\ Y\S\ Y\Y] S] Y\Y[ Y\Y\ Y\Y] Y]Y[ Y] Y\S\ Y]Y]S] Y]Y[ Y]Y\ Y]Y] ƒy]s\ Y\S] ƒy] Y\ S\ Y] ƒ Y[S] ƒy\ Y[S\ Y] ƒy[ ƒy\ Y[ Finl result, the mtrix for generl rottion round by ngle : FRV ƒfrv Y [Y [ Y [Y \ Y [Y ] Y \ Y [ Y\ Y \ Y\ Y ] VLQ ƒy ] Y \ Y ] ƒy [ ƒy \ Y[ Y ] Y [ Y] Y \ Y] Y ] S] S\ S] Order mtters! ( rottion * trnsltion trnsltion * rottion) Composition of trnsformtions = mtrix multipliction: if T is rottion nd S is scling, then pplying scling first nd rottion second is the sme s pplying trnsformtion given by the mtrix TS (note the order). Reversing the order does not work in most cses 2
Trnsformtion order Building the rm When we write trnsformtions using stndrd mth nottion, the closest trnsformtion to the point is pplied first: Strt: unit squre 756S 7 56S first, the object is scled, then rotted, then trnslted This is the most common trnsformtion order for n object (scle-rotte-trnslte) Step 1: scle to the correct size Building the rm step 2: trnslte to the correct position step 5: rotte the second box step 3: dd nother unit squre step 6: trnslte the second box step 4: scle the second box Positioning ech prt of complex object seprtely is difficult If we wnt to move whole complex objects consisting of mny prts or complex prts of n object (for exmple, the rm of robot) then we would hve to modify trnsformtions for ech prt solution: build objects hierrchiclly Ide: group prts hierrchiclly, ssocite trnsforms with ech group. whole robot = hed + body + legs + rms leg = upper prt + lower prt hed = neck + eyes + Hierrchicl representtion of n object is tree. The non-lef nodes re groups of objects. The lef nodes re primitives (e.g. polygons) Trnsformtions re ssigned to ech node, nd represent the reltive trnsform of the group or primitive with respect to the prent group As the tree is trversed, the trnsformtions re combined into one 3
Trnsformtion stck T nose nose robot S 1, T 1 hed body right left right leg leg rm eyes T hed upper prt lower prt left rm To keep trck of the current trnsformtion, the trnsformtion stck is mintined. Bsic opertions on the stck: push: crete copy of the mtrix on the top nd put it on the top pop: remove the mtrix on the top multiply: multiply the top by the given mtrix lod: replce the top mtrix with given mtrix TO drw the robot, we use mnipultions with the trnsform stck to get the correct trnsform for ech prt. For exmple, to drw the nose nd the eyes: push mult. T hed T hed lod S 1 mult. T 1 push T hed T hed mult. T nose T hed T nose T hed Drw the nose S 1 stck empty Sequence of opertions in the (pseudo)code: pop Drw the eyes T hed pop T hed push T hed T hed pop mult. T eyes T hed T eyes T hed Drw body etc lod S 1 ; mult T 1 ; push; mult. T hed ; push; mult T nose ; drw nose; push; mult. T eyes ; drw eyes; 4
Animtion The dvntge of hierrchicl trnsformtions is tht everything cn be nimted with little effort. Generl ide: before doing mult. or lod, compute trnsform s function of time. time = 0; min loop { drw(time); increment time; } drw( time ) { compute R rm (time) mult. R rm } 5