1 / 51

Review: Transformations

Review: Transformations. 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

rgaribay
Download Presentation

Review: Transformations

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Review:Transformations 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 CSE 681

  4. Transformations - Viewing CAMERA OBJECT WORLD CSE 681

  5. Modeling Transformations Transform objects/points Transform coordinate system 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 CSE 681

  7. Translation Translation by (tx, ty, tz): x’ = x + tx y’ = y + ty z’ = z + tz (tx, ty, tz) CSE 681

  8. Scaling Scaling by (sx, sy, sz): x’ = sx x y’ = sy y z’ = sz z CSE 681

  9. y r r   x z Rotation Rotation counter-clockwise by angle  around the z-axis: x’ = x cos() – y sin() y’ = x sin() + y cos() z’ = z • 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() 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  y x 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() y’ = y z’ = – x sin() + z cos() x  z y 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.) Scaling by (sx, sy, sz): x’ = sx x y’ = sy y z’ = sz z • Translation by (tx, ty, tz): • x’ = x + tx • y’ = y + ty • z’ = z + tz 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 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 Transformation Matrix: CSE 681

  16. y x z Shearing Shear along the x-axis: x’ = x + hy y’ = y z’ = z CSE 681

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

  18. Elementary Transformations • Translation • Rotation • Scaling • Shear CSE 681

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

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

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

  22. y y x x z z Order Matters! Transformations are not necessarily commutative! • Translate by (20, 0, 0). • Rotate by 30. • Rotate by 30. • Translate by (20, 0, 0). 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? CSE 681

  25. Elementary Transformations • 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) u P0 M M M u W Q(u) Q0 CSE 681

  29. Line • transformed point on a line ?= point on transformed line • M(P(u) T) ?= M(P0T + u* VT) 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}. • 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}. Theorem: Affine transformations transform lines to lines. CSE 681

  30. Affine Transformation of Lines y y x x z z CSE 681

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

  32. Affine Combinations Theorem: Affine transformations preserve 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’ 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 • 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 = ?. y j  i k x z CSE 681

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

  38. y y j  i k x x z z Orientation Right handed coordinate system: Left handed coordinate system: k j i  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. y j i  x z k Coordinate Transformations 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? CSE 681

  40. y x z Coordinate change (Translation) b (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. b (x, y, z) a c Coordinate change (Rotation) x y  z-axis rotation by  (0,0,0) z 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. y j j i i  x z k k f 1 0 é ù 0 x ê ú f 0 1 0 y ê ú . f 0 ê ú 0 1 z ê ú 0 0 0 1 ë û Object Transformations 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  CSE 681

  43. y j j i i  x z k k Object Transformations Affine transformation matrix: CSE 681

  44. y j i  x z k Coordinate Transformations 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 CSE 681

  45. y j i  x z k Coordinate Transformations T = R= CSE 681

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

  47. Composition of coordinate change y 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): ? y’ M1 y”  z M2 x x’ ’ z’ 0 x” z” CSE 681

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

  49. Transformations of normal vectors n 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 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 n n’ n CSE 681

More Related