Search code examples
c++openglmath3dquaternions

Quaternion representation or examples?


I'm studying 3D rendering with OpenGL, and Quaternions as used to describe rotation have me a bit stuck.

From what I've read so far, they are represented by no more than 4 numbers. What these 4 numbers are however, has me completely stumped. I've seen quaternions to be represented with a scalar (usually 1) then i, k, j, sometimes with a, b, c, d, sometimes mixed with both, then sometimes represented with w, x, y, z.

Do they represent different aspects of a Quaternion, or are they simply different letters for the same value? Were I to roll a Quaternion class, what 4 data members would I use of these? Do quaternions use more than 4 variables, but certain variables go ignored because 3D graphics uses a simplified version of actual quaternions appearing in math?

I think I could come to a far better understanding if I seen an implementation, even psuedo code, of quaternions in action. My brain shuts down the moment mathematical notation appears, unfortunately... If someone suggested an open source library that has clearly written quaternions I could learn from, regardless of language, it would be a tremendous help!


Solution

  • OGRE (Open Graphics Rendering Engine) has a good page at (mainly targeting developers):

    http://www.ogre3d.org/tikiwiki/Quaternion+and+Rotation+Primer

    And as OGRE is open source, you can also browse the source at:

    http://www.ogre3d.org/docs/api/1.9/class_ogre_1_1_quaternion.html