Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 91.427 Computer Graphics I, Fall 2010 Transformations.

Similar presentations


Presentation on theme: "1 91.427 Computer Graphics I, Fall 2010 Transformations."— Presentation transcript:

1 1 91.427 Computer Graphics I, Fall 2010 Transformations

2 2 91.427 Computer Graphics I, Fall 2010 Objectives Introduce standard transformations ­Rotation ­Translation ­Scaling ­Shear Derive homogeneous coordinate transformation matrices Learn to build arbitrary transformation matrices from simple transformations

3 3 91.427 Computer Graphics I, Fall 2010 General Transformations Transformation maps points to other points, and/or vectors to other vectors Q = T(P) v = T(u)

4 4 91.427 Computer Graphics I, Fall 2010 Affine Transformations Line preserving Characteristic of many physically important transformations ­Rigid body transformations: rotation, translation ­Scaling, shear Importance in graphics: ­only transform endpoints of line segments ­implementation draw line segment between transformed endpoints

5 5 91.427 Computer Graphics I, Fall 2010 Pipeline Implementation transformationrasterizer u v u v T T(u) T(v) T(u) T(v) vertices pixels frame buffer (from application program)

6 6 91.427 Computer Graphics I, Fall 2010 Notation Work with both coordinate-free representations of transformations and representations within particular frame P,Q, R: points in affine space u, v, w : vectors in affine space , ,  : scalars p, q, r : representations of points - array of 4 scalars in homogeneous coordinates u, v, w : representations of vectors - array of 4 scalars in homogeneous coordinates

7 7 91.427 Computer Graphics I, Fall 2010 Translation Move (translate, displace) point to new location Displacement determined by vector d ­Three degrees of freedom ­P’ = P + d P P’ d

8 8 91.427 Computer Graphics I, Fall 2010 How many ways? Can move point to new location in infinite ways, But when move many points usually only one way objecttranslation: every point displaced by same vector

9 9 91.427 Computer Graphics I, Fall 2010 Translation Using Representations Using homogeneous coordinate representation in some frame p = [ x y z 1] T p’ = [x’ y’ z’ 1] T d = [dx dy dz 0] T Hence p’ = p + d or x’ = x + d x y’ = y + d y z’ = z + d z Note: this expression is in 4-d and expresses point = vector + point

10 10 91.427 Computer Graphics I, Fall 2010 Translation Matrix Can also express translation using 4 x 4 matrix T in homogeneous coordinates p ’ = Tp where T = T (d x, d y, d z ) = Better for implementation because all affine transformations can be expressed this way and multiple transformations can be concatenated together

11 11 91.427 Computer Graphics I, Fall 2010 Rotation (2D) Consider rotation about origin by  degrees ­radius stays same, angle increases by  x’ = x cos  – y sin  y’ = x sin  + y cos  x = r cos  y = r sin  x = r cos (  y = r sin ( 

12 12 91.427 Computer Graphics I, Fall 2010 Rotation about the z axis Rotation about z axis in 3-d leaves all points with same z ­Equivalent to rotation in 2-d in planes of constant z ­or in homogeneous coordinates p ’ = R z (  )p x’ = x cos  – y sin  y’ = x sin  + y cos  z’ = z

13 13 91.427 Computer Graphics I, Fall 2010 Rotation Matrix R = R z (  ) =

14 14 91.427 Computer Graphics I, Fall 2010 Rotation about x and y axes Same argument as for rotation about z axis ­For rotation about x axis, x unchanged ­For rotation about y axis, y unchanged R = R x (  ) = R = R y (  ) =

15 15 91.427 Computer Graphics I, Fall 2010 Scaling S = S(s x, s y, s z ) = x’ = s x x y’ = s y x z’ = s z x p’ = Sp Expand or contract along each axis (fixed point of origin)

16 16 91.427 Computer Graphics I, Fall 2010 Reflection corresponds to negative scale factors original s x = -1 s y = 1 s x = -1 s y = -1s x = 1 s y = -1

17 17 91.427 Computer Graphics I, Fall 2010 Inverses Could compute inverse matrices by general formulas But can use simple geometric observations ­Translation: T -1 (d x, d y, d z ) = T (-d x, -d y, -d z ) ­Rotation: R -1 (  ) = R(-  ) Holds for any rotation matrix Note that since cos(-  ) = cos(  ) and sin(-  ) = -sin(  ) R -1 (  ) = R T (  ) ­Scaling: S -1 (s x, s y, s z ) = S(1/s x, 1/s y, 1/s z )

18 18 91.427 Computer Graphics I, Fall 2010 Concatenation Form arbitrary affine transformation matrices by multiplying together R, T, and S matrices Same transformation applied to many vertices ==> cost of forming matrix M = ABCD not significant compared to cost of computing Mp for many vertices p Difficult part: how to form desired transformation from specifications in application

19 19 91.427 Computer Graphics I, Fall 2010 Order of Transformations Note that matrix on right applied first Mathematically, equivalent p’ = ABCp = A(B(Cp)) Note: many references use column matrices to represent points In column matrices p ’T = p T C T B T A T

20 20 91.427 Computer Graphics I, Fall 2010 General Rotation About the Origin  x z y v Rotation by  about arbitrary axis can be decomposed into concatenation of rotations about x, y, and z axes R(  ) = R z (  z ) R y (  y ) R x (  x )  x  y  z called the Euler angles Note: rotations do not commute Can use rotations in another order but with different angles

21 21 91.427 Computer Graphics I, Fall 2010 Rotation About a Fixed Point other than the Origin Move fixed point to origin Rotate Move fixed point back M = T(p f ) R(  ) T(-p f )

22 22 91.427 Computer Graphics I, Fall 2010 Instancing In modeling, often start with simple object centered at origin, oriented with axis, and at standard size Apply instance transformation to its vertices to Scale Orient Locate

23 23 91.427 Computer Graphics I, Fall 2010 Shear Helpful to add one more basic transformation Equivalent to pulling faces in opposite directions

24 24 91.427 Computer Graphics I, Fall 2010 Shear Matrix Consider simple shear along x axis x’ = x + y cot  y’ = y z’ = z H(  ) =


Download ppt "1 91.427 Computer Graphics I, Fall 2010 Transformations."

Similar presentations


Ads by Google