1 / 44

CS 445 / 645: Introductory Computer Graphics

CS 445 / 645: Introductory Computer Graphics. Geometric Transforms. Matrix Manipulation - Example. Drawing a car with wheels and lugnuts. draw_wheel( ); for (j=0; j<5; j++) { glPushMatrix (); glRotatef(72.0*j, 0.0, 0.0, 1.0); glTranslatef (3.0, 0.0, 0.0); draw_bolt ( );

donkor
Download Presentation

CS 445 / 645: Introductory Computer Graphics

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. CS 445 / 645: Introductory Computer Graphics Geometric Transforms

  2. Matrix Manipulation - Example • Drawing a car with wheels and lugnuts draw_wheel( ); for (j=0; j<5; j++) { glPushMatrix (); glRotatef(72.0*j, 0.0, 0.0, 1.0); glTranslatef (3.0, 0.0, 0.0); draw_bolt ( ); glPopMatrix ( );

  3. Matrix Manipulation - Example draw_wheel( ); for (j=0; j<5; j++) { glPushMatrix (); glRotatef(72.0*j, 0.0, 0.0, 1.0); glTranslatef (3.0, 0.0, 0.0); draw_bolt ( ); glPopMatrix ( ); Global – Bottom Up Start Rot Trans

  4. Matrix Manipulation - Example draw_wheel( ); for (j=0; j<5; j++) { glPushMatrix (); glRotatef(72.0*j, 0.0, 0.0, 1.0); glTranslatef (3.0, 0.0, 0.0); draw_bolt ( ); glPopMatrix ( ); Local – Top Down Start Rot Trans

  5. Translation Matrices? • We can composite scale matrices just as we did rotation matrices • But how to represent translation as a matrix? • Answer: with homogeneous coordinates

  6. Homogeneous Coordinates • Homogeneous coordinates: represent coordinates in 3 dimensions with a 4-vector (Note that typically w = 1 in object coordinates)

  7. Homogeneous Coordinates • Homogeneous coordinates seem unintuitive, but they make graphics operations much easier • Our transformation matrices are now 4x4:

  8. Homogeneous Coordinates • Homogeneous coordinates seem unintuitive, but they make graphics operations much easier • Our transformation matrices are now 4x4:

  9. Homogeneous Coordinates • Homogeneous coordinates seem unintuitive, but they make graphics operations mucheasier • Our transformation matrices are now 4x4:

  10. Homogeneous Coordinates • Homogeneous coordinates seem unintuitive, but they make graphics operations much easier • Our transformation matrices are now 4x4:

  11. Homogeneous Coordinates • How can we represent translation as a 4x4 matrix? • A: Using the rightmost column:

  12. Translation Matrices • Now that we can represent translation as a matrix, we can composite it with other transformations • Ex: rotate 90° about X, then 10 units down Z:

  13. Translation Matrices • Now that we can represent translation as a matrix, we can composite it with other transformations • Ex: rotate 90° about X, then 10 units down Z:

  14. Translation Matrices • Now that we can represent translation as a matrix, we can composite it with other transformations • Ex: rotate 90° about X, then 10 units down Z:

  15. Translation Matrices • Now that we can represent translation as a matrix, we can composite it with other transformations • Ex: rotate 90° about X, then 10 units down Z:

  16. Transformation Commutativity • Is matrix multiplication, in general, commutative? Does AB = BA? • What about rotation, scaling, and translation matrices? • Does RxRy = RyRx? • Does RAS = SRA ? • Does RAT = TRA ?

  17. More On Homogeneous Coords • What effect does the following matrix have? • Conceptually, the fourth coordinate wis a bit like a scale factor

  18. Homogenous Coordinates • In particular, increasing w makes things smaller • We think of homogenous coordinates as defining a projective space • Increasing w “getting further away” • Will come in handy for projection matrices

  19. Projection Matrix • We talked about geometric transforms, focusing on modeling transforms • Ex: translation, rotation, scale, gluLookAt() • These are encapsulated in the OpenGL modelview matrix • Can also express projection as a matrix • Next few slides: representing orthographic and perspective projection with the projection matrix

  20. Orthographic Projection • Simple OrthographicTransformation • Original world units are preserved • Pixel units are preferred

  21. Orthographic: Screen Space Transformation left =10 m right = 20 m top=20 m (max pixx, max pixy) (height in pixels) (0, 0) bottom=10 m (width in pixels)

  22. Orthographic: Screen Space Transformation • left, right, top, bottom refer to the viewing frustum in modeling coordinates • width and height are in pixel units • This matrix scales and translates to accomplish the transition in units

  23. Perspective Transformation • First discovered by Donatello, Brunelleschi, and DaVinci during Renaissance • Objects closer to viewer look larger • Parallel lines appear to converge to single point

  24. Perspective Projection • In the real world, objects exhibit perspective foreshortening: distant objects appear smaller • The basic situation:

  25. How tall shouldthis bunny be? Perspective Projection • When we do 3-D graphics, we think of the screen as a 2-D window onto the 3-D world:

  26. Viewplane X P (x, y, z) x’ = ? (0,0,0) Z Perspective Projection • The geometry of the situation is that of similar triangles. View from above: • What is x’ ? d

  27. Perspective Projection • Desired result for a point [x, y, z, 1]T projected onto the view plane: • What could a matrix look like to do this?

  28. A Perspective Projection Matrix • Answer:

  29. A Perspective Projection Matrix • Example: • Or, in 3-D coordinates:

  30. Perspective Projection • Translate model units to pixel units

  31. Projection Matrices • Now that we can express perspective foreshortening as a matrix, we can composite it onto our other matrices with the usual matrix multiplication • End result: a single matrix encapsulating modeling, viewing, and projection transforms

  32. A 3D Scene • Notice the presence ofthe camera, theprojection plane, and the worldcoordinate axes • Viewing transformations define how to acquire the image on the projection plane

  33. Viewing Transformations • Create a camera-centered view • Camera is at origin • Camera is looking along negative z-axis • Camera’s ‘up’ is aligned with y-axis

  34. 2 Basic Steps • Align the two coordinate frames by rotation

  35. 2 Basic Steps • Translate to align origins

  36. Creating Camera Coordinate Space • Specify a point where the camera is located in world space, the eye point • Specify a point in world space that we wish to become the center of view, the lookat point • Specify a vector in worldspace that we wish to point up in camera image, the up vector • Intuitive camera movement

  37. Constructing Viewing Transformation, V • Create a vector from eye-point to lookat-point • Normalize the vector • Desired rotation matrix should map this vector to [0, 0, -1]T Why?

  38. Constructing Viewing Transformation, V • Construct another important vector from the cross product of the lookat-vector and the vup-vector • This vector, when normalized, should align with [1, 0, 0]TWhy?

  39. Constructing Viewing Transformation, V • One more vector to define… • This vector, when normalized, should align with [0, 1, 0]T • Now let’s composite the results

  40. Compositing Vectors to Form V • We know the three world axis vectors (x, y, z) • We know the three camera axis vectors (u, v, n) • Viewing transformation, V, must convert from world to camera coordinate systems

  41. Compositing Vectors to Form V • Remember • Each camera axis vector is unit length. • Each camera axis vector is perpendicular to others • Camera matrix is orthogonal and normalized • Orthonormal • Therefore, M-1 = MT

  42. Compositing Vectors to Form V • Therefore, rotation component of viewing transformation is just transpose of computed vectors

  43. Compositing Vectors to Form V • Translation component too • Multiply it through

  44. Final Viewing Transformation, V • To transform vertices, use this matrix: • And you get this:

More Related