Problems rotating my Sphere??

Hi all,

I’m having trouble rotating a sphere using the keys!!!
My problem is this:

When you press the Rotate Right Key the sphere rotate right (Y-Axis) which is correct.

When you press the Rotate Up Key the sphere rotate upwards (X-Axis) which is correct.

But,

If the sphere has rotate through 180 degrees upwards or downwards, the Rotate Right Key rotates Left. This is due to the Axis being flipped. How can I get around this?? I’m writing a very basic Top View (Looking down) move the ball through the maze type game.

I want the ball to always rotate in the direction of the key press.

I’ve heared something about quaternion <-spelling??? and ‘gimble lock’,is this the answer!? I fear these are abit over my head!!! Is it possible to fix my problem cleverly using glRotate ?? Matrices ?? As a newbie, I’m not really sure about matrices, so please help !! Do you know of any example source showing something similar???

Many thanks in advance.

The problem you are having stems from the fact that opengl rotates around the object not world axis (I think these are the right terms), basically, when you rotate around one axis all of the others rotate, so subsequent rotations are not what you expect. Quaternions are a solution, http://www.lboro.ac.uk/departments/ma/gallery/quat/intro.html
that is an excellent beginning
and http://www.cs.berkeley.edu/~laura/cs184/quat/quaternion.html
that, while tougher explains how to represent rotations. There are other was to solve your problem, but quaternions are quick and useful