Coordinate Sstems Point Representation in two dimensions Cartesian Coordinates: (; ) Polar Coordinates: (; ) (, ) ρ θ (ρ, θ) Cartesian Coordinates Polar Coordinates p = CPS1, 9: Computer Graphics D Geometric Transforms Page 1
Transformations (a) d (b) CPS1, 9: Computer Graphics D Geometric Transforms Page
Translation in D Moving the object along a line from one location to another. p = (; );t=(t ;t ); p 0 =( 0 ; 0 ) 0 =+t ; 0 =+t, p 0 =p+t. 0 0 = t t { } + T (t) (,) p t (, ) p t CPS1, 9: Computer Graphics D Geometric Transforms Page
Translation in D Translating a rigid bod: Translate ever point of b t. 0 = fp + t j p g: Enough to translate the vertices. CPS1, 9: Computer Graphics D Geometric Transforms Page
Rotation in D Rotation b with respect to origin. (, ) θ φ (,) = r cos ; = r sin : 0 = r cos( + ) = r cos cos, r sin sin = cos, sin : 0 = r sin( + ) = sin + cos : CPS1, 9: Computer Graphics D Geometric Transforms Page
Rotation in D 0 0 = cos, sin sin cos { } R() p 0 = R p Suppose R() = [R 1 () R ()]. R() 1 0 = cos sin = R 1 () R() 0 1 =, sin cos = R () CPS1, 9: Computer Graphics D Geometric Transforms Page
Rotation in D Rotation w.r.t. (; ): (, ) r (α,β) θ r φ (,) = + r cos ) r cos =, = + r sin ) r sin =, 0 = + r cos( + ) = + r cos cos, r sin sin = + (, ) cos, (, ) sin 0 = + (, ) sin + (, ) cos : CPS1, 9: Computer Graphics D Geometric Transforms Page
Scaling in D Scale b factor (s ;s ) 0 =s 0 =s 0 0 = s 0 0 s { } S(;) Uniform scaling s = s CPS1, 9: Computer Graphics D Geometric Transforms Page 8
Matri Representation of Transforms P 0 = AP + B Translation b (t ;t ): A = 1 0 0 1 B = t t Rotation b : A = cos, sin sin cos B = 0 0 Scaling b (s ;s ): A = s 0 0 s B = 0 0 CPS1, 9: Computer Graphics D Geometric Transforms Page 9
Composite Transformation T 1 = (A 1 ;B 1 ) T = (A ;B ) T T 1 (P) = A (A 1 P +B 1 )+B T T 1 CPS1, 9: Computer Graphics D Geometric Transforms Page 10
Noncommutativit of Transforms T : Translate (; 0); R: Rotate b = R T T R T R T CPS1, 9: Computer Graphics D Geometric Transforms Page 11
Homogeneous Coordinates Homogeneous coordinates unif translation, rotation, and scaling in one transformation matri. Transformation matri is matri. Translation p = (; ; w)! t = (t ;t ) w ; w p 0 = p+t= w +t ; w +t p 0 = (+t w; + t w; w) 0 0 w 0 = 1 0 t 0 1 t 0 0 1 { } w T(t ;t ) T (t ;t ),1 =T(,t ;,t ) CPS1, 9: Computer Graphics D Geometric Transforms Page 1
Homogeneous Coordinates Rotation 0 0 w 0 = cos, sin 0 sin cos 0 0 0 1 { } w R() R(),1 = R(,) Scaling 0 0 w 0 = s 0 0 0 s 0 0 0 1 { } w S(s ;s ) S(s ;s ),1 =S(1=s ; 1=s ) CPS1, 9: Computer Graphics D Geometric Transforms Page 1
D Rotation revisited Rotation w.r.t a point q (; ) b angle Regard as a composite transform. (α,β) (α,β) T (,;,) (α,β) (α,β) R()T (,;,) T (;)R()T (,;,) CPS1, 9: Computer Graphics D Geometric Transforms Page 1
D Rotation Translate b T (,;,) so that q becomes the origin. Rotate b with respect to the origin; R(). Translate b T (; ) to bring q back to its original position. R(; ; ) = T(; ) R() T (,;,): CPS1, 9: Computer Graphics D Geometric Transforms Page 1
D Rotation: Few Remarks Rotation involves either trigonometric functions or p Use Power series to approimate rotation for small values of Consider the upper-left matri of R() and regard the rows as vectors in the plane v 1 = (cos ;, sin ); v = (sin ; cos ): p (sinθ,cosθ) p R(θ) p (cos θ,-sin θ) CPS1, 9: Computer Graphics D Geometric Transforms Page 1
Euclidean Transform Euclidean transformation Rigid Bod transformations Translation and Rotation Angles and distances are unchanged T (; t ;t )= cos, sin t sin cos t 0 0 1 CPS1, 9: Computer Graphics D Geometric Transforms Page 1
Reection w.r.t -ais S(1;,1) w.r.t -ais S(,1; 1) What about w.r.t the line =,? CPS1, 9: Computer Graphics D Geometric Transforms Page 18
Shear Transform SH (a) = 1 a 0 0 1 0 0 0 1 0 = + a; 0 = : SH(a) Horiontal segment at height is shifted in the -direction b a. Not a Euclidean transform. 0 1 0 1 0 1 CPS1, 9: Computer Graphics D Geometric Transforms Page 19
D Transforms Homogeneous coordinates (; ; ; w) =) w ; w ; : w Right Hand Sstem: Positive rotation dened as: Look toward origin from a positive ais, = counter-clockwise 00 0000 11 1111 00 11 01 rotation transforms one ais to another. :!, :!, :!. 00 11 00 0000 11 1111 Some graphics sstems use the left hand sstem. CPS1, 9: Computer Graphics D Geometric Transforms Page 0
Translation Translation b (t ;t ;t ) p = (; ; ; w); t = (t ;t ;t ) p 0 = ( 0 ; 0 ; 0 ;w 0 ) = (+wt ;+wt ;+wt ;w): 0 0 0 w 0 = 1 0 0 t 0 1 0 t 0 0 1 t 0 0 0 1 { } w T(t ;t ;t ) T (t ;t ;t ),1 =T(,t ;,t ;,t ) CPS1, 9: Computer Graphics D Geometric Transforms Page 1
Scaling Scaling b (s ;s ;s ) p = (; ; ; w) s = (s ;s ;s ) p 0 = ( 0 ; 0 ; 0 ;w 0 )=(s ;s ;s ;w): 0 0 0 w 0 = s 0 0 0 0 s 0 0 0 0 s 0 0 0 0 1 { } w S(s ;s ;s ) S(s ;s ;s ),1 =S(1=s ; 1=s ; 1=s ) CPS1, 9: Computer Graphics D Geometric Transforms Page
Rotation in D Rotation w.r.t. a line: Ais of rotation Ais of rotation: -ais 0 = cos, sin 0 = sin + cos 0 = 00 0000 11 1111 00 0000 11 1111 00 11 01 00 11 0 0 0 w 0 = cos, sin 0 0 sin cos 0 0 0 0 1 0 0 0 0 1 { } w R () a (a) (b) CPS1, 9: Computer Graphics D Geometric Transforms Page
Rotation w.r.t. -ais Substitute! ;! ;!. 0 = cos, sin 0 = sin + cos 0 0 = 00 11 1 00 11 00 0000 11 1111 00 0000 11 1111 0 0 0 w 0 = 1 0 0 0 0 cos, sin 0 0 sin cos 0 0 0 0 1 { } w R () g (a) (b) CPS1, 9: Computer Graphics D Geometric Transforms Page
Rotation w.r.t. -ais Substitute! ;! ;! in the previous equations. 0 = cos, sin 0 = sin + cos 0 = 01 01 00 11 00 11 00 11 00 11 00 11 00 11 00 11 00 11 0 0 0 w 0 = cos 0 sin 0 0 1 0 0, sin 0 cos 0 0 0 0 1 { } w R () b (a) (b) CPS1, 9: Computer Graphics D Geometric Transforms Page
Rotation wrt a Point p f u p f (a) (b) p f p f R(; p) = T(p) R () T(,p) CPS1, 9: Computer Graphics D Geometric Transforms Page
Transformations in OpenGL Vertices CTM Vertices glmatrimode (mode) Species the matri that will be modied. GL MODELVIEW, GL PROJECTION, GL TEXTURE. glloadidentit () Sets the current matri to the identit matri. glloadmatriffdg (tpe *M) Sets the current matri to M. glmultmatriffdg (tpe *M) Multiplies the current matri b M; C: current matri. C = C M: CPS1, 9: Computer Graphics D Geometric Transforms Page
Transformations in OpenGL gltranslateffdg (,, ) Translates an object b (; ; ). C = C T (; ; ) glscaleffdg (,, ) Scales an object b (; ; ). C = C S(; ; ) glrotateffdg (,,, ) Rotates an object b angle w.r.t. the ra emanating from the origin to the point (; ; ). C = C R(; ; ; ) CPS1, 9: Computer Graphics D Geometric Transforms Page 8
Order of multiplication Last transformation is applied rst! glloadidentit(); glmultmatrif (L); glmultmatrif (M); glmultmatrif (N); glbegin(gl POINT) glvertef(v); glend(); C = I C = L C = L M C = L M N v 0 = C v = L M N v CPS1, 9: Computer Graphics D Geometric Transforms Page 9
Order of multiplication T R gltranslatef (T ); glrotatef (R); Assume the object comes with its own coordinate sstem. Keep the object coordinates the same as world coordinates and transform the object. Transform the object coordinate sstem. CPS1, 9: Computer Graphics D Geometric Transforms Page 0
Multiple Coordinate sstems C i : i-th coordinate sstem. P (i) : Coordinates of P in C i M ij : Transformation C j! C i. C P (i) = M ij P (j) : C C1 M ik = M ij M jk M ij = M,1 ji : Q (j) : A geometric transform in C j. Q (i) = M ij Q (j) M ji = M ij Q (j) M,1 ij : CPS1, 9: Computer Graphics D Geometric Transforms Page 1
Multiple Coordinate Sstems wo World-coordinate sstem tr Triccle-coordinate sstem wo wh tr tr wo wh wh Wheel-coordinate sstem Coordinate sstems: World, triccle, wheels As the front wheel rotates around its -ais: Both wheels rotate about the -aes of wheels coordinate sstem. Triccle moves as a whole. Both triccle and wheels move w.r.t world coordinates. Wheel and triccle coordinates are related b translation in and directions and rotation in -direction. CPS1, 9: Computer Graphics D Geometric Transforms Page