cmsc427 transformations i
play

CMSC427 Transformations I Credit: slides 9+ from Prof. Zwicker - PowerPoint PPT Presentation

CMSC427 Transformations I Credit: slides 9+ from Prof. Zwicker Transformations: outline Types of transformations Specific: translation, rotation, scaling, shearing Classes: rigid, affine, projective Representing transformations


  1. CMSC427 Transformations I Credit: slides 9+ from Prof. Zwicker

  2. Transformations: outline • Types of transformations • Specific: translation, rotation, scaling, shearing • Classes: rigid, affine, projective • Representing transformations • Unifying representation with homogeneous coordinates • Transformations represented as matrices • Composing transformations • Sequencing matrices • Sequencing using OpenGL stack model • Transformation examples • Rotating or scaling about a point • Rotating to a new coordinate frame • Applications • Modeling transformations (NOW) • Viewing transformations (LATER)

  3. Modeling with transformations • Object coordinate • Create instance of space object in object coordinate space • Create circle at origin • Transform object to • World coordinate space world coordinate space • Scale by 1.5 • Move down by 2 unit • Do so for other objects • Two rects make hat • Three circles make body • Two lines make arms

  4. Classes of transformations • Rigid • Affine • Translate, rotate, • Translate, rotate, scale uniform scale (non-uniform), shear, reflect • No distortion to object • Limited distortions • Preserve parallel lines

  5. Classes of transformations • Affine • Projective • Preserves parallel lines • Foreshortens • Lines converge • For viewing/rendering

  6. Classes of transformations: summary • Affine • Reshape, size object • Rigid • Place, move object • Projective • View object • Later … • Non-linear, arbitrary • Twists, pinches, pulls • Not in this unit

  7. First try: scale and rotate vertices in vector notation • Scale a point p by s and 𝑟 = 𝑡 ∗ 𝑞 + 𝑈 translate by T 𝑟 = 2 ∗ 2,3 +< 2,2 > • Vector multiplication and 𝑟 = (6,8) addition • Repeat and we get q 𝑟 = 𝑡 ( 𝑡 ∗ 𝑞 + 𝑈 + 𝑈 ( T • Gets unwieldy p • Instead – unify notation with homogeneous coordinates and matrices

  8. Matrix practice 𝑁 = 2 0 𝑁𝑆 = 2 2 1 0 1 3 = 0 2 0 0 𝑆 = 1 1 𝑆𝑁 = 1 1 2 0 2 = 0 3 0 3 0 𝑄 = 2 𝑁𝑄 = 2 0 2 2 3 = 3 0

  9. Matrix practice 𝑁 = 2 0 𝑁𝑆 = 2 2 1 0 3 = 2 1 7 1 2 1 0 1 6 𝑆 = 1 1 𝑆𝑁 = 1 1 2 0 2 = 3 2 0 3 0 3 1 3 6 𝑄 = 2 𝑁𝑄 = 2 2 2 0 3 = 4 3 1 8

  10. Matrix transpose and column vectors 9 𝑆 9 = 1 1 = 0 3 9 𝐼 9 = 2 1 3 = 4 1 5 𝑄 = 2 3 9 3 = 2

  11. Matrix transpose and column vectors 9 𝑆 9 = 1 1 = 1 0 0 3 1 3 2 4 9 𝐼 9 = 2 1 3 = 1 1 4 1 5 3 5 𝑄 = 2 3 9 3 = 2

  12. Matrices Abstract point of view • Mathematical objects with set of operations • Addition, subtraction, multiplication, multiplicative inverse, etc. • Similar to integers, real numbers, etc. But • Properties of operations are different • E.g., multiplication is not commutative • Represent different intuitive concepts • Scalar numbers represent distances • Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 12

  13. Matrices Practical point of view • Rectangular array of numbers • Square matrix if • In graphics often 13

  14. Matrix addition 14

  15. Multiplication with scalar 15

  16. Matrix multiplication 16

  17. Matrix multiplication 17

  18. Matrix multiplication 18

  19. Matrix multiplication 19

  20. Matrix multiplication Special case: matrix-vector multiplication 20

  21. Linearity • Distributive law holds i.e., matrix multiplication is linear http://en.wikipedia.org/wiki/Linear_map • But multiplication is not commutative , in general 21

  22. Identity matrix 22

  23. Matrix inverse Definition If a square matrix is non-singular, there exists a unique inverse such that • Note • Computation • Gaussian elimination, Cramer’s rule (OctaveOnline) • Review in your linear algebra book, or quick summary http://www.maths.surrey.ac.uk/explore/emmaspages/option1.html 23

  24. Java vs. OpenGL matrices • OpenGL (underlying 3D graphics API used in the Java code, more later) http://en.wikipedia.org/wiki/OpenGL • Matrix elements stored in array of floats float M[16]; • “Column major” ordering • Java base code • “Row major” indexing • Conversion from Java to OpenGL convention hidden somewhere in basecode! 24

  25. T oday Transformations & matrices • Introduction • Matrices • Homogeneous coordinates • Affine transformations • Concatenating transformations • Change of coordinates • Common coordinate systems 25

  26. Vectors & coordinate systems • Vectors defined by orientation, length • Describe using three basis vectors 26

  27. Points in 3D • How do we represent 3D points? • Are three basis vectors enough to define the location of a point? 27

  28. Points in 3D • Describe using three basis vectors and reference point, origin 28

  29. Vectors vs. points • Vectors • Points • Representation of vectors and points using 4 th coordinate is called homogeneous coordinates 29

  30. Homogeneous coordinates • Represent an affine space http://en.wikipedia.org/wiki/Affine_space • Intuitive definition • Affine spaces consist of a vector space and a set of points • There is a subtraction operation that takes two points and returns a vector • Axiom I: for any point a and vector v , there exists point b , such that (b-a) = v • Axiom II: for any points a, b, c we have (b-a)+(c-b) = c-a 30

  31. Affine space Vector space, Affine space http://en.wikipedia.org/wiki/Vector_space http://en.wikipedia.org/wiki/Affine_space • [xyz] coordinates • [xyz1], [xyz0] • represents vectors homogeneous coordinates • distinguishes points and vectors 31

  32. Homogeneous coordinates • Subtraction of two points yields a vector • Using homogeneous coordinates 32

  33. T oday Transformations & matrices • Introduction • Matrices • Homogeneous coordinates • Affine transformations • Concatenating transformations • Change of coordinates • Common coordinate systems 33

  34. Affine transformations • Transformation, or mapping: function that maps each 3D point to a new 3D point „ f: R 3 -> R 3 “ • Affine transformations: class of transformations to position 3D objects in space • Affine transformations include • Rigid transformations • Rotation • Translation • Non-rigid transformations • Scaling • Shearing 34

  35. Affine transformations • Definition: mappings that preserve colinearity and ratios of distances http://en.wikipedia.org/wiki/Affine_transformation • Straight lines are preserved • Parallel lines are preserved • Linear transformations + translation • Nice: All desired transformations (translation, rotation) implemented using homogeneous coordinates and matrix-vector multiplication 35

  36. Translation Point Vector 36

  37. Matrix formulation Point Vector 37

  38. Matrix formulation • Inverse translation • Verify that 38

  39. Note • What happens when you translate a vector? 39

  40. Rotation First: rotating a vector in 2D • Convention: positive angle rotates counterclockwise • Express using rotation matrix 40

  41. Rotating a vector in 2D 41

  42. Rotating a vector in 2D 42

  43. Rotating a vector in 2D 43

  44. Rotation in 3D Rotation around z-axis • z-coordinate does not change v 0 = R z ( µ )v • What is the matrix for ? 44

  45. Other coordinate axes • Same matrix to rotate points and vectors • Points are rotated around origin 45

  46. Rotation in 3D • Concatenate rotations around x,y,z axes to obtain rotation around arbitrary axes through origin are called Euler angles • http://en.wikipedia.org/wiki/Euler_angles • Disadvantage: result depends on order! Gimbal https://en.wikipedia.org/wiki/Gimbal 46

  47. Rotation around arbitrary axis • Still: origin does not change • Counterclockwise rotation • Angle , unit axis • • Intuitive derivation see http://mathworld.wolfram.com/RotationFormula.html 47

  48. Summary • Different ways to describe rotations mathematically • Sequence of rotations around three axes (Euler angles) • Rotation around arbitrary angles (axis-angle representation) • Other options exist (quaternions, etc.) • Rotations preserve • Angles • Lengths • Handedness of coordinate system • Rigid transforms • Rotations and translations 48

  49. Rotation matrices • Orthonormal • Rows, columns are unit length and orthogonal • Inverse of rotation matrix? 49

  50. Rotation matrices • Orthonormal • Rows, columns are unit length and orthogonal • Inverse of rotation matrix? • Its transpose 50

  51. Rotations • Given a rotation matrix • How do we obtain ? 51

  52. Rotations • Given a rotation matrix • How do we obtain ? 52

  53. Rotations • Given a rotation matrix • How do we obtain ? • How do we obtain …? 53

  54. Rotations • Given a rotation matrix • How do we obtain ? • How do we obtain …? 54

  55. Scaling • Origin does not change 55

  56. Scaling • Inverse scaling? 56

  57. Scaling • Inverse scaling? 57

  58. Shear • Pure shear if only one parameter is non-zero • Cartoon-like effects 58

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend