Upcoming Events
Southwest Gaming Expo
11/20 - 11/22 @ Dallas, TX

Workshop on Network and Systems Support for Games (NetGames 2009)
11/23 - 11/25 @ Paris, France

ICIDS 2009 Interactive Storytelling
12/9 - 12/11 @ Guimarães, Portugal

Global Game Jam
1/29 - 1/31  

More events...


Quick Stats
6627 people currently visiting GDNet.
2341 articles in the reference section.

Help us fight cancer!
Join SETI Team GDNet!



Link to us

Link to us

  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