Contents
How does the glrotatef function in Win32 work?
The glRotatef function computes a matrix that performs a counterclockwise rotation of angle degrees about the vector from the origin through the point (x, y, z). The current matrix (see glMatrixMode) is multiplied by this rotation matrix, with the product replacing the current matrix.
Why does a cube rotate along a Y axis?
At the moment I click, the cube will stop rotating along Z and start to rotate along Y. But it turns out it will rotate along a “new and invisible” Y-axis. I figure out that’s because when I rotate the cube along Z with glRotatef (), the other two axis:X,Y also rotate.
How is the current matrix replaced in glrotatef?
The current matrix (see glMatrixMode) is multiplied by this rotation matrix, with the product replacing the current matrix. That is, if M is the current matrix and R is the translation matrix, then M is replaced with M R. If the matrix mode is either GL_MODELVIEW or GL_PROJECTION, all objects drawn after glRotatef is called are rotated.
Is it possible to rotate an object around a fixed axis?
What you’re after might be accumulating arbitrary rotations. This can’t be done with euler angles, which gimbal lock. It’s pretty common to have euler angle rotations and in most cases the issue is simply to do with the order they’re applied in. The first thing I’d suggest is to reverse the order of your x/y/z rotations.
How to rotate a triangle in OpenGL 2.1?
In this OpenGL 2.1 tutorial we are going to use the glRotatef () method. In the example below I will use a black background and draw 3 triangles. The green will rotate around the X axis. The blue will rotate around the Y axis. The red will rotate around the Z axis.
Is the sum and rotation of glrotate the same?
Now return the original position, and rotate it 90 degrees in X, then 90 degrees in Y. Note that the orientation is different. While it is possible to find a rotation which would produce the same result as either of the orderings, it is not the same as the sum.