PDA

View Full Version : Question about rotations... (first time poster)



jacksmash
12-07-2007, 03:07 PM
Hi everyone,

Very simple question (although I'm not sure why the answer isn't so simple to me!).

I would like to rotate an object around some fixed coordinate system. Problem is, when you begin one rotation around a given axis, this rotation affects all subsequent rotations.

I'm sure many have experienced this problem. Problem is, I'm not sure how to search for related topics because I cannot explain the problem in just a couple of words! I've tried several searches, but to no avail (so far).

The OpenGL wiki suggests that the use of quaternions might help solve this problem - but the suggested link is broken. I've never even heard of a quaternion - sounds like it's out of Star Trek or something :P

Anyhow, I promise to keep searching for solutions. But if anyone could suggest any direction I would greatly appreciate it. I'll look into quaternions as well... but I it's sounds like overkill for my situation.

Thanks in advance!

Zengar
12-08-2007, 02:05 AM
If you google for quaternions, you will find plenty of explanation (they are simple and very nice). Basicaly, they allow you to rotate something around a vector.

Trenki
12-08-2007, 04:14 AM
You can also rotate around an arbitrary axis with glRotate. Maybe this is enough for your purposes?

[ www.trenki.net (http://www.trenki.net) | vector_math (3d math library) (http://www.trenki.net/content/view/16/36/) | software renderer (http://www.trenki.net/content/view/18/38/) ]

jacksmash
12-08-2007, 09:55 AM
I'll look into quaternions.

As for the second response - glRotate is fine if you're only rotating around a singular axis. As soon as you rotate around another, things get funny.

plasmonster
12-08-2007, 10:41 PM
The rotation that OpenGL performs on vectors is almost identical to what you would get with a quaternion (see the formulation given on page 45 of the specification and compare that to a quaternion rotation of q* (0,v) q).

The trouble lies in concatenating rotation matrices, or repeatedly rotating individual basis vectors, which are not likely to remain orthogonal.

Fixed Euler angle rotation sequences are just fine if you understand their limitations.