1 / 41

Transformation of objects 2D transformations 3D transformations Matrix representation

Transformation of objects 2D transformations 3D transformations Matrix representation OpenGL functions. Rendering Pipeline. Rendering Pipeline. Basic 2D Transformations. Basic 2D Transformations. Matrix representation. Combination of 2D transformations. 2x2 matrices. 2x2 matrices.

yoko
Download Presentation

Transformation of objects 2D transformations 3D transformations Matrix representation

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. Transformation of objects 2D transformations 3D transformations Matrix representation OpenGL functions

  2. Rendering Pipeline

  3. Rendering Pipeline

  4. Basic 2D Transformations

  5. Basic 2D Transformations

  6. Matrix representation

  7. Combination of 2D transformations

  8. 2x2 matrices

  9. 2x2 matrices

  10. 2x2 matrices

  11. 2x2 matrices • Only rotation, scaling, and shear can be represented in 2x2 matrix form. • These are linear transformations.

  12. Linear transformations

  13. 2D Translation: 3x3 matrix

  14. Homogeneous coordinates

  15. Basic 2D transformations in homogeneous coordinates

  16. Affine transformations

  17. Matrix compositions

  18. Matrix compositions

  19. 3D transformations

  20. Basic 3D transformations

  21. Basic 3D transformations

  22. Rotation about an arbitrary point Alternative Form for a Rotation About a Point. From Example 5.2.5, we have Qx= cos() Px - sin() Py + dx = cos() Px - sin() Py - cos() Vx + sin() Vy + Vx = cos()( Px – Vx) - sin() (Py – Vy) + Vx Qy is same as Qx.

  23. P=(4,7) 45 degrees about V(5,4)

  24. Reflection about the axis at angle 

  25. (-3, 3), (0,3), (0,5) to (0,0) (2,0) (1, sqrt(3))

  26. Rotate P(1,2,-1) after 45 degrees

  27. OpenGL Matrix Stacks OpenGL works with stacks of 4x4 matrices: glMatrixMode(enum mode); mode: GL_MODELVIEWGL_PROJECTIONGL_TEXTURE Specifies whether the modelview, projection or texture matrix will be modified.

  28. OpenGL Matrix Stacks glLoadIdentity(void); Clears the currently modifiable matrix for future transformation instructions. Typically we call this instruction before specifying modeling, viewing or projection transformations.

  29. OpenGL Matrix Stacks Manipulating stacks: the OpenGL calls to push, pop, or multiply top of stack glLoadMatrix {fd}(const TYPE *m); sets 16 value of the current matrix glMultMatrix {fd}(const TYPE *m)); multiply by m glPushMatrix(void); the topmost matrix is copied glPopMatrix(void); the topmost matrix is destroyed All vertices of the object are multiplied by the matrix.

  30. OpenGL Matrix Stacks Manipulating stacks: the OpenGL calls to push, pop, or multiply top of stack glLoadMatrix(const type *m); glMultMatrix(const type *m); m1 m5 m9 m13 m2 m6 m10 m14 m3 m7 m11 m15 m4 m8 m12 m16

  31. OpenGL Transformations glTranslate(TYPE x, TYPE y, TYPE z); Multiplies the current matrix by a translation matrix. glRotate(TYPE angle, TYPE x, TYPE y, TYPE z); Multiplies the current matrix by a rotation matrix. glScale(TYPE x, TYPE y, TYPE z); Multiplies the current matrix by a scaling matrix.

  32. //additional methods for Canvas class //components of 2D transformation //<<<<<<<<<<<<<<< initCT >>>>>>>>>>>>>>>>> void Canvas:: initCT(void) { glMatrixMode(GL_MODELVIEW); glLoadIdentity(); // set CT to the identity matrix } //<<<<<<<<<<<<<< scale2D >>>>>>>>>>>>>>>>>>>> void Canvas:: scale2D(double sx, double sy) { glMatrixMode(GL_MODELVIEW); glScaled(sx, sy, 1.0); // set CT to CT * (2D scaling) } //<<<<<<<<<<<<<<< translate2D >>>>>>>>>>>>>>>>> void Canvas:: translate2D(double dx, double dy) { glMatrixMode(GL_MODELVIEW); glTranslated(dx, dy, 1.0); // set CT to CT * (2D translation) } //<<<<<<<<<<<<<<<< rotate2D >>>>>>>>>>>>>>>>>>>> void Canvas:: rotate2D(double angle) { glMatrixMode(GL_MODELVIEW); glRotated(angle, 0.0, 0.0, 1.0); // set CT to CT * (2D rotation) }

  33. void Canvas:: pushCT(void) { glMatrixMode(GL_MODELVIEW); glPushMatrix(); // push a copy of the top matrix } void Canvas:: popCT(void) { glMatrixMode(GL_MODELVIEW); glPopMatrix(); // pop the top matrix from the stack }

  34. gluLookAt()

More Related