PDA

View Full Version : a problem about ROTATION, help plz.



arjie
11-10-2002, 06:28 PM
I want image continuesly rotation controled by hand.
For example if i press left key then image rotate horizontally,
I want to control the image in 6 direction(left ,right ,up ,down ,outside and inside according to the screen).
At first I use
glPushMatrix();
glRotatef(X.XX,1.0,0.0,0.0);
glRotatef(X.XX,0.0,1.0,0.0);
glRotatef(X.XX,0.0,0.0,1.0);
DrawScene();
glPopMatrix();
But it can't rotate according to screen(in another word , rotate in a fixed coordinate), later rotate axis was affected by the former rotation.if have a example code will be the best.
thanks a lot, help me please.
my e-mail: arjie_yes@hotmail.com

ctoa
11-10-2002, 09:57 PM
use quaternion

arjie
11-10-2002, 10:17 PM
thank ctoa for replying. But I don't know quaternion. http://www.opengl.org/discussion_boards/ubb/frown.gif
Could you please explain it?or give me a sample code.

arjie
11-10-2002, 10:22 PM
I have use glMultMatrixf(float &a);but i can only let image rotate according it's own axis; but it can't rotate according to the fixed axis(Such as whenever I press left key image will rotate to screen left).My matrix calculation was wrong.

[This message has been edited by arjie (edited 11-11-2002).]

NordFenris
11-11-2002, 06:52 AM
To do what I think you want to do you will get away by using glLoadIdentity() before drawing and rotating your model.

steveo
11-12-2002, 04:18 AM
The problem you are having is called 'gimbal lock'. You need to use a quaternion to represent the rotation, you can turn a quaternion into a rotation matrix and then use glMultMatrix().
There is a good FAQ on quaternions at -http://www.cs.ualberta.ca/~andreas/math/matrfaq_latest.html.

Hope this helps,

Steve O'Connor

John Jenkins
11-12-2002, 06:24 AM
Cool I was wondering what was wrong with my rotations now I know, Gimbal Locks.

arjie
11-16-2002, 02:11 AM
thanks for steveo's helping.
I solve my problem.
thanks again.

paulc
11-16-2002, 02:37 PM
If you want to know about quaternions there is a good pdf on David Eberly's site Magic Software (http://www.magic-software.com) . Look in the Documentation (http://www.magic-software.com/Documentation.html) section for the article on 'Quaternion Algebra and Calculus'. One stop shop for quaternion knowledge.