1 Lecture 7 Geometrical Transformations: 2D transformations 3D transformations Matrix representation OpenGL functions
2 Rendering Pipeline
3
4
5
6 Basic 2D Transformations
7
8
9 Matrix representation
10 Combination of 2D transformations
11 2x2 matrices
12 2x2 matrices
13 2x2 matrices
14 2x2 matrices
15 2x2 matrices Only rotation, scaling, and shear can be represented in 2x2 matrix form. These are linear transformations.
16 Linear transformations
17 2D Translation: 3x3 matrix
18 Homogeneous coordinates
19 Basic 2D transformations in homogeneous coordinates
20 Affine transformations
21 Projections
22 Matrix compositions
23 Matrix compositions
24 Matrix compositions
25 3D transformations
26 Basic 3D transformations
27 Basic 3D transformations
28 OpenGL Matrix Stacks OpenGL works with stacks of 4x4 matrices: glMatrixMode(enum mode); mode: GL_MODELVIEW GL_PROJECTION GL_TEXTURE Specifies whether the modelview, projection or texture matrix will be modified.
29 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.
30 OpenGL Matrix Stacks Manipulating stacks: the OpenGL calls to push, pop, or multiply top of stack glLoadMatrix(void); glMultMatrix(void); glPushMatrix(void); the topmost matrix is copied glPopMatrix(void); the topmost matrix is destroyed All vertices of the object are multiplied by the matrix.
31 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
32 OpenGL Matrix Stacks Manipulating stacks: the OpenGL calls to push, pop, or multiply top of stack glPushMatrix(void); the topmost matrix is copied glPopMatrix(void); the topmost matrix is destroyed All vertices of the object are multiplied by the matrix.
33 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.
34 Summary Types of transformations: –linear –affine –projective Representation of transformations: –3x3 and 4x4 matrices –homogeneous coordinates Compositions of transformations OpenGL Matrix Instructions