PDA

View Full Version : How to find object orientation?



ChrisT
05-08-2001, 11:14 AM
Hi,

I try to explain you my problem. I take an example. I have some cubes with different textures on each face. The goal is to rotate the cubes to built the good image like a puzzle. Now i want to know when someone wins the game i.e. when the cubes are in the correct orientation. I can store the 3 angles on x, y and z but as you preaphs know, making a rotation on y and on x and on z ... is not making a rotation on z and on y and on x. The order is important. So i can't only compare the actual x,y,z angles to some final x,y,z values. In other words, i can't say the cube is in the correct orientation for instance if x=250,y=120,z=30.
Is someone has an idea, it will help me very much.

thanks http://www.opengl.org/discussion_boards/ubb/smile.gif

Teofuzz
05-08-2001, 01:20 PM
Keep a local system of vectors xloc, yloc and zloc...
I heard about quaternions, but I still ignore what they are http://www.opengl.org/discussion_boards/ubb/redface.gif
However they (maybe) have to do with your problem...
tFz

john
05-08-2001, 04:10 PM
Hello,

quaternions are a way of expressing rotations. Its theory is based on an extension to the complex number system with even more imaginary numbers. Ultimately, however, quaternions spefify a rotation by a rotation about some arbitrary vector. In fact, the parameter glRotate*() is actually a quaternion. They're specially useful for tweening rotations. Check out:

"Animating Rotation with Quaternion Curves," K.Shoemake, Ccomputer Graphcis, V.19 N3, 1985

and

"Smooth Interpolation of Orientations with Angular Veolcoity Constraints using Quaternions", A.H.Barr, B.Currin, S.Gabriel, J.F.Hughes, Computer Graphics 26, 2, 1992

cheers
John

ChrisT
05-08-2001, 10:18 PM
hi,

Thank you for your help. http://www.opengl.org/discussion_boards/ubb/smile.gif

harsman
05-09-2001, 02:25 AM
glRotate is a quaternion? I always assumed it was and axis and an angle?

DFrey
05-09-2001, 04:02 AM
Correct, glRotate is an axis and angle, not a quaternion. An axis and angle does map one to one and onto the set of unit quarternions however. But that mapping has nothing to do with glRotate.