Upcoming Events
Unite 2010
11/10 - 11/12 @ Montréal, Canada

GDC China
12/5 - 12/7 @ Shanghai, China

Asia Game Show 2010
12/24 - 12/27  

GDC 2011
2/28 - 3/4 @ San Francisco, CA

More events...
Quick Stats
89 people currently visiting GDNet.
2406 articles in the reference section.

Help us fight cancer!
Join SETI Team GDNet!
Link to us Events 4 Gamers
Intel sponsors gamedev.net search:

  Contents

 Introduction
 Let's Get Started
 Quaternions
 Converting from
 Quaternions

 Multiplying
 Quaternions

 Conversion to
 Quaternions

 Demo
 Conclusion

 Printable version

 


Let's get started

Before we begin, let's establish some assumptions I'll be making. I hate the way many articles leave this important section out, causing a great deal of confusion when it comes to the mathematics.

Coordinate System - This article assumes a right hand coordinate system, like OpenGL. If you are using a left handed coordinate system like Direct3D, you may need to transpose the matrices. Note that the Direct3D samples have a quaternion library already, though I recommend you check through their implementation before using it.

Rotation Order - The sequence of rotations in the Euler representation is X, then Y, and then Z. In matrix form:

RotX * RotY * RotZ      <-- Very Important

Matrix - Matrices are in column major format, like they are in OpenGL.

Example [ 0  4  8  12
          1  5  9  13
          2  6  10 14
          3  7  11 15 ]

Vectors and Points - Implemented as a 4x1 matrix so applying a transformation is of the order

Rotation Matrix*  [ vx
                    vy
                    vz
                    1  ]  <-- 4x1 vector

This does not imply that I prefer OpenGL over Direct3D. It just happened that I learned OpenGL first, and so my quaternion knowledge was gained in OpenGL.

Note: If you specify rotations in another order, certain quaternion functions will be implemented differently, especially those that deal with Euler representation.




Next : Quaternions