Question

What is the difference between

glRotatef(angle, 1.0f, 0.0f, 0.0f);
glRotatef(angle, 0.0f, 0.0f, 1.0f);

and

glRotatef(angle, 1.0f, 0.0f, 1.0f);

And why nothing change when I change the second paramater 1.0f to 5.0f? Lastly, how can I rotate an object around x=5 and not around x=0?

Was it helpful?

Solution

If you want to rotate around x=5 you should do a glTranslate to x=5 and whatever your y coordinate is and then do glRotate then glTranslate back to the origin.

So something like

glTranslate(5, 0, 0);
glRotatef(...);
glTranslate(-5, 0, 0);

For the first question I'm including @genpfault's answer for completeness. It is due to vector normalization done by glRotatef() on the vector you pass in.

OTHER TIPS

And why nothing change when I change the second paramater 1.0f to 5.0f?

The vector you pass glRotatef() is normalized before use.

You cannot simply sum rotations by adding the axes together, it does not produce the same resulting concatenated transform. If it did, it would suggest that transformations are commutative, which they are clearly not.

Pick up an object and rotate it 90 degrees around the Y axis, and then 90 degrees around the X axis. Look at how it is oriented. 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.

Nothing changes when you vary the other parameters (provided you scale them uniformly) as the rotation axis is normalised.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top