Implementing Transformation Sequences
Calculate the matrices and cumulatively multiply them into a global Current Transformation Matrix
Postmultiplication is more convenient in hierarchies - multiplication is computed in the opposite order of function application
The calculation of the transformation matrix, M,
- initialize M to the identity
- in reverse order compute a basic transformation matrix, T
- post-multiply T into the global matrix M, M ? MT
Example - to rotate by theta around [x,y]:
Remember the last T calculated is the first applied to the points
- calculate the matrices in reverse order
glLoadIdentity() /* initialize M to identity mat.*/
glTranslatef(x, y, 0) /* LAST: undo translation */
glRotatef(theta,0,0,1) /* rotate about z axis */
glTranslatef(-x, -y, 0) /* FIRST: move [x,y] to origin. */