Advertisement

Quat rotation / glRotatef

Started by November 25, 2002 04:50 AM
3 comments, last by aker_jus 22 years, 3 months ago
After seeing the example at GameTutorials about Quaternions, I found the whole subject fascinating, but I have one question. WIll quaternion based rotation be somewhat slower than normal glRotatef call? I ask this because there are so many calls (CreateMatrix, glMultMatrixf, etc) to make a rotation. Should I dig into quats or stay with glRotatef for simple rotations??
GraphicsWare|RenderTechhttp://www.graphicsware.com3D Graphics & Solutions
aker_jus, first you must understand the ups and downs of each method.

Quaternions, while being complex to calculate, get around the gimbal lock problem. It makes sense to use quaternions for stuff like camera orientation, bone animation, etc. You will invariably need sense-independent rotation for your camera system.

If all you want is a rotating object (somewhat like the objects in Quake3) then simple glTranslatefs and glRotatefs will suffice.

Its all upto the use of the algorithm.

PS : Its better to know all methods then eliminate what is not required. You never know, you might need it somewhere.

Regs,
HellSpawn
(^-^)
Advertisement
I make my camera using glLookAt, how would I change that to use quaternions?

Thanks
GraphicsWare|RenderTechhttp://www.graphicsware.com3D Graphics & Solutions
Aren''t quaternions faster since they require only one matrix multiplication + the calculations for creating the quaternion as compared to 3 matrix multiplications ?

Also doesnt the gimbal lock problem still exist if you create the quaternion from euler angles, rather from a single angle and a vector ? e.g. if you want to rotate an object by (45, 90, 180) degrees create the quaternion from the angle 180 and the vector (0.25, 0.5, 1.0).

Nitzan

-------------------------
www.geocities.com/nitzanw
www.scorchedearth3d.net
-------------------------
Quaternions are just a way of representing sense-independent rotation. Of course, you can screw up the most impeccable and accurate methods. The idea is to implement it correctly.

Of course, there are a lot of other methods available. One of them is an adaptation of the axis angle method. I have written an article about it, which you can find here >>

http://rasterized.tripod.com/Articles/CameraClass.html

There is a quaternion camera tutorial on Nehe''s site, here is the link

http://nehe.gamedev.net/trentp/gametutorials/lesson07.asp

This should get you started.
(^-^)

This topic is closed to new replies.

Advertisement