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 CSE 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 CSE 681

3 Transformations - Modeling
Object parts defined in their own object coordinate spaces Transform them relative to each other to assemble object CSE 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 CSE 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) CSE 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. CSE 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. CSE 681

8 Scaling Scaling by (sx, sy, sz): x’ = sx x y’ = sy y z’ = sz z CSE 681
Scaling is an affine transformation. Note: Location of lower left corner of house is changed CSE 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? CSE 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 CSE 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 CSE 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 CSE 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 CSE 681

14 Rotation Matrices 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() Rotation counter-clockwise by angle  around the z-axis: x’ = x cos() – y sin() y’ = x sin() + y cos() z’ = z CSE 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) CSE 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. CSE 681

17 Reflection Reflection across the x-axis: x’ = (-1) x y’ = y z’ = z
Use this with rhs of world to lhs of amera Reflection is a special case of scaling! CSE 681

18 Elementary Transformations
Translation Rotation Scaling Shear CSE 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) CSE 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. CSE 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). CSE 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 CSE 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). CSE 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. CSE 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). CSE 681

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

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

28 Transform Parametric Line
V P(u) P0 u M Q(u) M M u W Q0 CSE 681

29 Line transformed point on a line ?= point on transformed line
M(P(u) T) ?= M(P0T + u* VT) 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. CSE 681

30 Affine Transformation of Lines
y y Which points don’t change? z x z x CSE 681

31 Affine Combinations Q R b a P M R’ M M b a Q’ P’ CSE 681

32 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. CSE 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. Affine transformations [does/does not] preserve angles? Affine transformations [does/does not] the intersection of two lines? Affine transformations [does/does not] preserve distances? CSE 681

34 Properties of Transformation Matrices
First column is how (1,0,0,0) transforms Second column is how (0,1,0,0) transforms Third column is how (0,0,1,0) transforms Matrix holds how coordinate axes transform and how origin transforms CSE 681

35 Properties of Pure Rotation Matrices
Rows (columns) are orthogonal to each other A row dot product any other row = 0 Each row (column) dot product times itself = 1 RT = R-1 CSE 681

36 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 = ?. CSE 681

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

38 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? CSE 681

39 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 (x, y, z) 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. CSE 681

40 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: Move (a,b,c, ) to (x,y,z,0) and invert Move data relative from (0,0,0) out to  position by adding  CSE 681

41 Coordinate change (Rotation)
(x, y, z) a b y x z-axis rotation by  (0,0,0) z What does (1,0,0) trasform to? What does (0,1,0) transform to? What does (0,0,1) transform to? Change from (a,b,c,) coordinates to (x,y,z,0) coordinates: Rotate (a,b,c) by  and invert Rotate data by - CSE 681

42 Object Transformations
k . 1 ú û ù ê ë é f z y x x z y i j k Given (i,j,k,p) defined in the (x,y,z,0) coordinate frame, Transform points defined in the (i, j, k, ) coordinate frame to the (x,y,z,0) coordinate frame. Rotate object to get x to line up with i, then translate to  x,y,z,0 are mapped to i,j,k,, respectively. CSE 681

43 Object Transformations
x z y i j k i j k x,y,z,0 are mapped to i,j,k,, respectively. Affine transformation matrix: CSE 681

44 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 (x,y,z,0) coordinate frame to (i, j, k, ) coordinate frame. Apply transform to coordinate system, then invert: Coordinate system transform: translate by - , then rotate to align i with x x,y,z,0 are mapped to i,j,k,, respectively. CSE 681

45 Coordinate Transformations
x z y i j k x,y,z,0 are mapped to i,j,k,, respectively. T = R= CSE 681

46 Coordinate Transformations
x z y i j k Apply RT to coordinate system Apply (RT)-1 to data = T-1R-1 x,y,z,0 are mapped to i,j,k,, respectively. Affine transformation matrix: CSE 681

47 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): ? CSE 681

48 Composition of transformations - example
B’ y B q A x CSE 681

49 Transformations of normal vectors
n is a unit normal vector to plane . M is an affine transformation matrix. How is n transformed, to keep it perpendicular to the plane, under: translation? rotation by ? uniform scaling by s? shearing or non-uniform scaling? CSE 681

50 Shear transformation n n’ n
n is a unit normal vector to plane : (-nx,0) M is a shear transformation matrix that only modifies x-coordinates If we just transform the n as a vector, then M nT = n But we want n’ – that has a non-zero y-coordinate value CSE 681

51 Transformations of normal vectors
Planar equation: a x + b y + c z + d = 0. Let N = (a, b, c, d). (Note: (a, b, c) is normal vector) 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 (transformed planar equation) 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 to take NT into N’T Note: If M is a rotation matrix, (M-1)T = M. n P CSE 681


Download ppt "Review: Transformations"

Similar presentations


Ads by Google