Question
In many of the OpenGL programs we have used this semester, object rotation was implemented using the following lines of code in the display callback:
In many of the OpenGL programs we have used this semester, object rotation was implemented using the following lines of code in the display callback:
glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glRotatef(xangle, 1.0, 0.0, 0.0); // rotate x glRotatef(yangle, 0.0, 1.0, 0.0); // rotate y glRotatef(zangle, 0.0, 0.0, 1.0); // rotate z
The parameters xangle, yangle, zangle are global variables that are initialized to zero. In the keyboard callback these global variables are incremented by 5 degrees when the user types X, Y, or Z and decremented by 5 degrees when the user types x, y, or z.
a) What will the three rotation angles be if the user types in XXXyyZxx?
b) What would happen if the user input xxZyyXXX instead? Explain.
c) Assuming there are no other changes to the GL_MODELVIEW matrix, what is the order
in which the three rotation operations above are applied to polygon vertices.
d) In general, does the order of operation matter when applying a sequence of rotations?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started