Presentation is loading. Please wait.

Presentation is loading. Please wait.

Review: Transformations

Similar presentations


Presentation on theme: "Review: Transformations"— Presentation transcript:

1 Review: Transformations
Need to transform points and vectors Transform object data from object space to world space CIS 681

2 Transformations Modeling transformations
build complex models by positioning (transforming) simple components relative to each other Viewing transformations placing virtual camera in the world transformation from world coordinates to camera coordinates Perspective projection of 3D coordinates to 2D Animation vary transformations over time to create motion CIS 681

3 Transformations - Modeling
Object parts defined in their own object coordinate spaces Transform them relative to each other to assemble object CIS 681

4 Transformations - Viewing
CAMERA OBJECT Object defined in object space is transformed into world space Camera with its own local coordinate system is transformed into world space Need object relative to camera coordinate system WORLD CIS 681

5 Modeling Transformations
Transform objects/points Transform coordinate system Can think of transformation either as: Transforming object relative to fixed coordinate system transforming coordinate system that object is in (e.g. moving camera) CIS 681

6 Affine Transformations
Transform P = (x, y, z) to Q = (x’, y’, z’). Affine transformation: x’ = m11 x + m12 y + m13 z + m14 y’ = m21 x + m22 y + m23 z + m24 z’ = m31 x + m32 y + m33 z + m34 Math name of what we’re interested in: Affine transformations Means: Linear equations. CIS 681

7 Translation Translation by (tx, ty, tz): x’ = x + tx; y’ = y + ty;
z’ = z + tz. (tx, ty, tz) Translation is an affine transformation. CIS 681

8 Scaling Scaling by (sx, sy, sz): x’ = sx x; y’ = sy y; z’ = sz z.
Scaling is an affine transformation. Note: Location of lower left corner of house is changed CIS 681

9 Rotation Rotation counter-clockwise by angle  around the z-axis:
x’ = x cos() – y sin() ; y’ = x sin() + y cos() ; z’ = z. x z y r Proof: x = r cos(); y = r sin(); x’ = r cos( + ) = r cos() cos() – r sin() sin() = x cos() – y sin(); y’ = r sin( + ) = r cos() sin() + r sin() cos() = x sin() + y cos(); USE RIGHT HAND RULE Rotation is an affine transformation. (x,y,z) =( r*cos(alpha), r*sin(alpha) , z) Another viewpoint: Where do the points (1, 0, 0) and (0, 1, 0) go? CIS 681

10 Rotation around x-axis
Rotation counter-clockwise by angle  around the x-axis: x’ = x; y’ = y cos() – z sin() ; z’ = y sin() + z cos() . z x y CIS 681

11 Rotation around y-axis
Rotation counter-clockwise by angle  around the y-axis: y’ = y; z’ = z cos() – x sin() ; x’ = z sin() + x cos(). Or x’ = x cos() + z sin(); z’ = – x sin() + z cos(). x Note: Here x plays role of y in rotation around z-axis. y z CIS 681

12 Matrix Multiplication
Scaling by (sx, sy, sz): x’ = sx x; y’ = sy y; z’ = sz z. Rotation counter-clockwise by angle  around the z-axis: x’ = x cos() – y sin() ; y’ = x sin() + y cos() ; z’ = z. Translation by (tx, ty, tz): x’ = x + tx; y’ = y + ty; z’ = z + tz. CIS 681

13 Homogeneous Coordinates
Represent P by (x, y, z, 1) and Q by (x’, y’, z’, 1). (Homogeneous coordinates.) Translation by (tx, ty, tz): x’ = x + tx; y’ = y + ty; z’ = z + tz. Scaling by (sx, sy, sz): x’ = sx x; y’ = sy y; z’ = sz z. CIS 681

14 Rotation Matrices Rotation counter-clockwise by angle  around the z-axis: x’ = x cos() – y sin() ; y’ = x sin() + y cos() ; z’ = z. Rotation counter-clockwise by angle  around the x-axis: x’ = x; y’ = y cos() – z sin() ; z’ = y sin() + z cos() . Rotation counter-clockwise by angle  around the y-axis: x’ = x cos() + z sin(); y’ = y; z’ = – x sin() + z cos(). CIS 681

15 Affine Transformation Matrix
x’ = m11 x + m12 y + m13 z + m14 y’ = m21 x + m22 y + m23 z + m24 z’ = m31 x + m32 y + m33 z + m34 Transformation Matrix: Translation in right colum Scale along diagonal (uniform or non uniform) Rotation elsewhere Rigid transformations (w/ uniform scale) CIS 681

16 Shearing Shear along the x-axis: x’ = x + hy; y’ = y; z’ = z. y x z
Note change in location of lower left corner of house. Can construct shear by combination of rotations and non-uniform scaling. CIS 681

17 Reflection Reflection across the x-axis: x’ = (-1) x; y’ = y; z’ = z.
Reflection is a special case of scaling! CIS 681

18 Elementary Transformations
Translation; Rotation; Scaling; Shear. CIS 681

19 Compose Transformations
Rotate by 30° counter-clockwise around the z-axis; x z y Scale by (2, 1, 1); Translate by (20, 5, 0); Translate by (0, -50, 0). CIS 681

20 Compose Transformation Matrices
Rotate by 30° counter-clockwise around the z-axis; Rotate Scale by (2, 1, 1); Scale x z y Translate by (20, 5, 0); Translate Translate by (0, -50, 0). Translate Multiply matrices together. Real advantage of matrix multiplication/homogeneous coordinates. CIS 681

21 Compose Transformation Matrices
Scale by (2, 1, 1); x z y Translate by (20, 5, 0); Rotate by 30° counter-clockwise around the z-axis; Translate by (0, -50, 0). CIS 681

22 Order Matters! Transformations are not necessarily commutative!
Translate by (20, 0, 0). Rotate by 30. Rotate by 30. Translate by (20, 0, 0). x z y x z y CIS 681

23 Order of Transformation Matrices
Apply transformation matrices from right to left. Translate by (20, 0, 0). Rotate by 30. Rotate by 30. Translate by (20, 0, 0). CIS 681

24 Which transformations commute?
Translation and translation? Scaling and scaling? Rotation and rotation? Translation and scaling? Translation and rotation? Scaling and rotation? Uniform scaling and rotation commute. CIS 681

25 Elementary Transformations
Translation; Rotation; Scaling; Shear. Theorem: Every affine transformation can be decomposed into elementary operations. Euler’s Theorem: Every rotation around the origin can be decomposed into a rotation around the x-axis followed by a rotation around the y-axis followed by a rotation around the z-axis. (or a single rotation about an arbitrary axis). CIS 681

26 Vectors Vector V = (Vx, Vy, Vz).
Homogeneous coordinates: (Vx, Vy, Vz, 0). Affine transformation: CIS 681

27 Vectors Rotation: Scaling: Translation: (Note: No change.) CIS 681

28 Line Line through P0 = (x, y, z, 1) in direction V = (Vx, Vy, Vz, 0):
P(u) = P0T + u* VT {(x0, y0, z0, 1) + u* (Vx, Vy, Vz, 0): u  Reals}. Apply affine transformation matrix M to line P(u): M *P(u) { M (P0T + u VT) : u  Reals} = { M P0T + uM VT : u  Reals} = { Q0 + u V’ : u  Reals}. Theorem: Affine transformations transform lines to lines. CIS 681

29 Affine Transformation of Lines
y y Which points don’t change? z x z x CIS 681

30 Affine Combinations Q R b a P b a Q’ R’ P’ CIS 681

31 Affine Combinations Affine combinations of P = (x, y, z, 1) and Q = (x’, y’, z’, 1): {R = a (x, y, z, 1) + b (x’, y’, z’, 1): a,b  Reals and a + b = 1} Apply affine transformation matrix M to (a PT + b QT) gives: M (a PT + b QT) = M a PT + M b QT = a M PT + b M QT = a P’ + b Q’ = MR = R’ Theorem: Affine transformations preserve affine combinations. CIS 681

32 Affine Combinations Theorem: The affine combination of points P and Q is the line through P and Q. Affine combinations of P = (x, y, z, 1) and Q = (x’, y’, z’, 1): {a (x, y, z, 1) + b (x’, y’, z’, 1): a,b  Reals and a + b = 1}. a = 1- b so a (x, y, z, 1) + b (x’, y’, z’, 1) = (1-b) (x, y, z, 1) + b (x’, y’, z’, 1) = (x, y, z, 1) + b ((x’, y’, z’, 1) – (x, y, z, 1)) = (x, y, z, 1) + b(x’-x, y’-y, z’-z, 0) = P + b*V Where V = Q-P CIS 681

33 Properties of Affine Transformations
Affine transformations map lines to lines; Affine transformations preserve affine combinations; Affine transformations preserve parallelism; Affine transformations change volume by | Det(M) |; Any affine transformation can be decomposed into elementary transformations. CIS 681

34 Coordinate Frame y j i k z x Coordinate frame is given by origin  and three mutually orthogonal unit vectors, i, j, k - defined in (x,y,z) space Mutually orthogonal (dot products): i•j = ?; i•k = ?; j•k = ?. Unit vectors (dot products): i•i = ?; j•j = ?; k•k = ?. CIS 681

35 Orientation Right handed coordinate system:
Left handed coordinate system: x z y y (Into page) z x (Out of page) CIS 681

36 Orientation Right handed coordinate system: Left handed coordinate system: k x z y i j k x z y j i How could you test if the I,j,k coordinate frame is right-handed or left-handed Cross product: i x j = ? Cross product: i x j = ? How do you test whether (i,j,k) is left handed or right handed? CIS 681

37 Coordinate Transformations
x z y i j k Given object data points defined in the (i, j, k, ) coordinate frame, Given the definition of (i, j, k, ) in into (x, y, z, 0) coordinates, How do you determine the coordinates of the object data points in the (x, y, z, 0) frame? x,y,z,0 are mapped to i,j,k,, respectively. CIS 681

38 Coordinate change (Translation)
b x z y (x, y, z) a (0,0,0) c Change from (a,b,c,) coordinates to (x,y,z,0) coordinates: CIS 681

39 Coordinate change (Rotation)
(x, y, z) a b y x z-axis rotation by  (0,0,0) z Change from (a,b,c,) coordinates to (x,y,z,0) coordinates: CIS 681

40 Coordinate Transformations
x z y i j k Given (I,j,k,p) defined in the (x,y,z,0) coordinate frame, Transform points in (i, j, k, ) coordinate frame to (x, y, z, 0) coordinate frame. x,y,z,0 are mapped to i,j,k,, respectively. Affine transformation matrix: Maps (i, j, k, ) coordinates into (x, y, z, 0) coordinates! CIS 681

41 Composition of coordinate change
y y’ M1 y” z M2 x ’ x’ z’ z” x” M1 changes from coordinate frame (x,y,z,) to (x’,y’,z’,’). M2 changes from coordinate frame (x’,y’,z’,’) to (x’’,y’’,z’’,’’). Change from coordinate frame (x,y,z,) to (x’’,y’’,z’’,0): ? CIS 681

42 Object vs. coordinate transformations
Translate and then rotate object: z x y z x y z x y Translate and then rotate coordinate frame: z x y z’’ ’’ x’’ y’’ z x y z’ ’ x’ y’ z x y CIS 681

43 Object vs. coordinate transformations (2)
Translate and then rotate object: z x y z x y z x y Rotate and then translate coordinate frame: z’’ ’’ x’’ y’’ z x y z x y y’ z x y x’ ’ z’ CIS 681

44 Order of transformations
Let Mi be the transformation matrix for transformation Ti. Sequence of object (point) transformations, T1, T2, T3. Transformation matrix = M3 x M2 x M1. Sequence of coordinate system transformations, T1, T2, T3. Transformation matrix = M1 x M2 x M3. Note: OpenGL, OpenInventor use coordinate system transformations. CIS 681

45 Transformations of normal vectors
n is a unit normal vector to plane . M is an affine transformation matrix. How is n transformed under: translation? rotation by ? uniform scaling by s? shearing or non-uniform scaling? CIS 681

46 Shear transformation n n’ n n is a unit normal vector to plane .
M is the shear transformation matrix. M nT = n! Want n’. CIS 681

47 Transformations of normal vectors
Planar equation: a x + b y + c z + d = 0. Let N = (a, b, c, d). (Note: n = (a, b, c) for some real .) Let P = (x, y, z, 1) be a point in plane . Planar equation: N • P = 0. M is an affine transformation matrix. (MT is M transpose.) Let P’ = M PT. Find N’ such that N’ • P’ = 0. N • P = 0; N PT = 0; N (M-1 M) PT = 0; (N M-1) (M PT) = 0; (N M-1) P’T = 0; So N’ = NM-1 To put in column-vector form, (N’)T = (NM-1)T = (M-1)TNT So N’ = ((M-1)T NT)T and (M-1)T is the transformation matrix for N. Note: If M is a rotation matrix, (M-1)T = M. n P CIS 681


Download ppt "Review: Transformations"

Similar presentations


Ads by Google