The chief cause of problems is solutions! Concept 1.7: The order of transformations ======================================== Idea: ===== In OpenGL the order in which transformations are specified have a definite effect on where the object is rendered. A translation followed by a rotation leads to a much different scenario than vice versa. Experiment: =========== Enter values of 2, 2, -3 for Translation and values of 45, 1, 1, 0 for rotation. Execute the code. Now use the toggle switch to specify a rotation first and then a translation in the code. Did you see a difference? Click on the Reset button. Now enter (3, 0, 0) for specifying the translation and (45, 0, 1, 0) (i.e. a 45 degree rotation about the Y axis) for the rotation. Click on execute. Now use the toggle switch again. Question ======== Why does the order of transformations affect the final image? Answer ====== Let us evaluate the input values of (3, 0, 0) for translation and (45, 0, 1,0) for rotation. Initially the order is as follows : glTranslatef(3, 0, 0); glRotatef(45, 0, 1, 1); drawcube(); Here a rotation about the Y axis is performed while still at the origin. Next we translate the rotated cube about the X axis When we use the toggle the code changes to glRotatef(45, 0, 1, 0); glTranslatef(3, 0, 0): drawcube(); Here we first translate 3 units along the X axis and then we rotate 45 degrees along the Y axis. This rotation can be viewed as travelling 45 degrees along a circle whose center isat the origin and radius is 3 units along the X axis.