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

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
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

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

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.

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).]

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.

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.

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

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.