Quaternion C++ Class

Download Now!

Here we have provided a C++ class for quaternional algebra. You need these two files: quaternion.h & quaternion.c++. To be able to work with Euler angles, you also need to download Ken Shoemake's QuatTypes.h, EulerAngles.h, EulerAngles.c and define SHOEMAKE in your makefile. Here is an example how to use it all together: (test.c++) and a makefile. For more on quaternions, read Prof. George Francis's introduction lecture.

Introduction to Quaternionial Algebra

Quaternions are elements of the 4-dimensional space  formed by the real axis and 3 imaginary orthogonal axes , , and  that obey Hamilton’s rule .  They can be written in a standard quaternionial form as  where , or as a 4D vector  where  is called scalar part and  is called vector part.  Quaternions possess the following properties:

Addition: for

Multiplication: for  and

 is the magnitude of ,  is its norm.  If , the quaternion  is referred to as a unit quaternion.  For   is a unit quaternion.  Inverse of  is defined as  and the conjugate of  is defined as .  For any unit quaternion  we have .  Quaternions whose real part is zero are called pure quaternions.

Rotation of a 3D vector  by a unit quaternion  is defined as  where  is a pure quaternion build from  by adding a zero real part.  Sequences of rotations can be conveniently represented as the quaternionial product.  For example, if  is rotated by  followed by , the result is the same as  rotated by .

 


Document is created by Angela Bennett and Volodymyr Kindratenko
Last modified: Tuesday, August 29, 2000 11:00:00 AM