1 / 38

Geometry: 2-D Transformations

Geometry: 2-D Transformations. Course web page: http://www.gomezconsultants.com. Chapter #3. Why We Need Transformations. What can we do so far? Draw 2-D shapes by exhaustively listing their vertices Allow user interaction Something missing:

joannbowen
Télécharger la présentation

Geometry: 2-D 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. Geometry: 2-D Transformations Course web page: http://www.gomezconsultants.com Chapter #3

  2. Why We Need Transformations • What can we do so far? • Draw 2-D shapes by exhaustively listing their vertices • Allow user interaction • Something missing: • The ability to specify the intrinsic shape of an object independently of its location, scale, or orientation

  3. Example: Shape vs. Viewing Issues

  4. Example: Shape vs. Viewing Issues

  5. Example: Shape vs. Viewing Issues

  6. Example: Shape vs. Viewing Issues

  7. Transformations for modeling, viewing • Make object model in idealized coordinate frame • Transform object with appropriate translation, scaling, rotation as needed • Also useful for building complex objects from simpler parts from Hill

  8. Notes on Notation • Vectors, points: x, v (assume column vectors) • Matrices: R, T • Scalars: x, a • Axes, objects: X, Y, O • Coordinate systems: W, C • Specials • Transpose operator: xT (as opposed to x0) • Identity matrix: Id • Matrices/vectors of zeroes, ones: 0, 1

  9. 2-D Transformations • Types • Translation • Scaling • Rotation • Shear, reflection • Mathematical representation • OpenGL functions for applying

  10. 2-D Translation

  11. 2-D Translation

  12. 2-D Translation

  13. 2-D Translation

  14. 2-D Translation

  15. 2-D Scaling

  16. 2-D Scaling

  17. 2-D Scaling sx 1 Horizontal shift proportional to horizontal position

  18. 2-D Scaling sy 1 Vertical shift proportional to vertical position

  19. 2-D Scaling

  20. 2-D Scaling

  21. 2-D Rotation

  22. 2-D Rotation This is a counterclockwise rotation

  23. 2-D Rotation µ This is a counterclockwise rotation

  24. 2-D Rotation

  25. 2-D Rotation

  26. 2-D Rotation (uncentered)

  27. 2-D Rotation (uncentered)

  28. 2-D Shear (horizontal)

  29. 2-D Shear (horizontal) Horizontal displacement proportional to vertical position

  30. 2-D Shear (horizontal)

  31. 2-D Reflection (vertical)

  32. 2-D Reflection (vertical) Just a special case of scaling—”negative” scaling

  33. 2-D Reflection (vertical)

  34. 2-D Transformations: OpenGL • 2-D transformation functions* • glTranslate(x, y, 0) • glScale(sx, sy, 0) • glRotate(theta, 0, 0, 1) (angle in degrees; direction is counterclockwise) • Notes • Set glMatrixMode(GL_MODELVIEW) first • Transformations should be specified before drawing commands to be affected • Multiple transformations are applied in reverse order *Technically, these are 3-D

  35. Example: 2-D Translation in OpenGL Two ways to do this: glRectf(.25,.25,.75,.75); glTranslatef(.5,.5,0); glRectf(-.25,-.25,.25,.25);

  36. Example: Order of transformations glRotatef(45,0,0,1); glTranslatef(.5,.5,0); glRectf(-.25,-.25,.25,.25); glTranslatef(.5,.5,0); glRotatef(45,0,0,1); glRectf(-.25,-.25,.25,.25); Remember: Order of application is backwards from drawing commands

  37. Limiting “Scope” of Transformations • Transformations are ordinarily applied to all subsequent draw commands • To limit effects, use push/pop functions: glPushMatrix(); // transform // draw affected by transform glPopMatrix(); // draw unaffected by transform

  38. Example: Pushing, popping transformations glPushMatrix(); glTranslatef(.5,.5,0); glRotatef(45,0,0,1); glRectf(-.25,-.25,.25,.25); glPopMatrix(); glPushMatrix(); // draw axis lines glPopMatrix();

More Related