rotation question
If I rotate a cube like this:
1)
glRotatef( 0, 1.0f, 0.0f, 0.0f);
glRotatef(45, 0.0f, 1.0f, 0.0f);
glRotatef(45, 0.0f, 0.0f, 1.0f);
drawCube()
it draws differently from this:
2)
glRotatef(45, 0.0f, 0.0f, 1.0f);
glRotatef(45, 0.0f, 1.0f, 0.0f);
glRotatef( 0, 1.0f, 0.0f, 0.0f);
drawCube()
or this:
3)
glRotatef(45, 0.0f, 0.0f, 1.0f);
glRotatef( 0, 1.0f, 0.0f, 0.0f);
glRotatef(45, 0.0f, 1.0f, 0.0f);
drawCube()
Why does this happen ? 2 and 3 draws the same rotated cube, but in 1 its not rotated quite the same. Is this Gimbal Lock ?
I implemented quaternions and it also drew it like in numbers 2 and 3.
Any help would be appreciated.
Nitzan
-------------------------
www.geocities.com/nitzanw
www.scorchedearth3d.net
-------------------------
Rotation is not commutative. Think about it: if you rotate a body around the x-axis, it''s already changed its poisition on the x-axist. The results of now rotating it around the z-axis doesn''t logically place the body in the same position as first rotating it around z-axis and then around the x-axis. It''s a simple think-about-it-yourself question.
Hope this helps,
Crispy
Hope this helps,
Crispy
You''re multiplying matrices when you call glRotate, glTranslate, glScale. Matrix multiplication is not commutative.
Also, if You are familiar with matrices, You know, that matrix of rotation (f-angle) around say z axis is:
(It will be different for other 2 axes)
Now performing several rotation is the same as multiplying corresponding matrices - but matrix multiplication is not commutative => result will be different!
If You are unfamiliar with matrices, then just take thick book, and try to rotate it around axis passing the walls of your room You''ll notice the difference
cos(f) sin(f) 0-sin(f) cos(f) 0 0 0 1
(It will be different for other 2 axes)
Now performing several rotation is the same as multiplying corresponding matrices - but matrix multiplication is not commutative => result will be different!
If You are unfamiliar with matrices, then just take thick book, and try to rotate it around axis passing the walls of your room You''ll notice the difference
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement