banner.gif
On-Line Computer Graphics Notes
QUATERNIONS


Overview

The quaternion number system was discovered by Hamilton, a physicist who was looking for an extension of the complex number system to use in geometric optics. Quaternions have developed a wide-spread use in computer graphics and robotics research because they can be used to control rotations in three dimensional space. In these notes we define and review the basic properties of quaternions.

pdficonsmall.gif For a pdf version of these notes look here


What are Quaternions?

Remember complex numbers? These numbers are an extension of the real number system and can be written in the form $ a +b\imath$, where $ a$ and $ b$ are both real numbers and $ \imath^2=-1$. The quaternions are just an extension of this complex number form.

A quaternion is usually written as

$\displaystyle {\mathsf q } \: = \: a + b {\mathsf i } + c {\mathsf j } + d {\mathsf k }
$

where $ a$, $ b$, and $ c$ are scalar values, and $ {\mathsf i } $, $ {\mathsf j } $ and $ {\mathsf k } $ are the unique quaternions with the properties that

$\displaystyle {\mathsf i } ^2 = -1, \, {\mathsf j } ^2 = -1, \, {\mathsf k } ^2 = -1
$

and
\begin{singlespace}
\begin{align*}
{\mathsf i } {\mathsf j } & = {\mathsf k } ,...
...\\
{\mathsf i } {\mathsf k } & = - {\mathsf j }
\end{align*}\end{singlespace}

This is clearly an extension of the complex number system - where the complex numbers are those quaternions that have $ c = d = 0$ and the real numbers are those that have $ b = c = d = 0$.


Adding and Multiplying Quaternions

Addition of quaternions is very straightforward: We just add the coefficients. That is, if $ {\mathsf q } _1 = a_1 + b_1 {\mathsf i } + c_1 {\mathsf j } + d_1 {\mathsf k } $ and $ {\mathsf q } _2 = a_2 + b_2 {\mathsf i } + c_2 {\mathsf j } + d_2 {\mathsf k } $, then the sum of the two quaternions is

$\displaystyle {\mathsf q } _1 + {\mathsf q } _2 \: = \:
( a_1 + a_2 ) +
( b_1 + b_2 ) {\mathsf i } +
( c_1 + c_2 ) {\mathsf j } +
( d_1 + d_2 ) {\mathsf k }
$

Multiplication is somewhat more complicated, as we must first multiply componentwise, and then use the product formulas for $ {\mathsf i } $, $ {\mathsf j } $, and $ {\mathsf k } $ to simplify the resulting expression. So the product of $ {\mathsf q } _1$ and $ {\mathsf q } _2$ is

$\displaystyle {\mathsf q } _1 {\mathsf q } _2$ $\displaystyle = \left( a_1 + b_1 {\mathsf i } + c_1 {\mathsf j } + d_1 {\mathsf...
...ht) \left( a_2 + b_2 {\mathsf i } + c_2 {\mathsf j } + d_2 {\mathsf k } \right)$    
  $\displaystyle = a_1 a_2 + a_1 b_2 {\mathsf i } + a_1 c_2 {\mathsf j } + a_1 d_2...
...hsf i } + b_1 c_2 {\mathsf i } {\mathsf j } + b_1 d_2 {\mathsf i } {\mathsf k }$    
  $\displaystyle \quad + c_1 a_2 {\mathsf j } + c_1 b_2 {\mathsf j } {\mathsf i } ...
...hsf i } + d_1 c_2 {\mathsf k } {\mathsf j } + d_1 d_2 {\mathsf k } {\mathsf k }$    
  $\displaystyle = \left ( a_1 a_2 - b_1 b_2 - c_1 c_2 - d_1 d_2 \right) + \left ( a_1 b_2 + a_2 b_1 + c_1 d_2 - d_1 c_2 \right) {\mathsf i }$    
  $\displaystyle \quad + \left ( a_1 c_2 + a_2 c_1 + d_1 b_2 - b_1 d_2 \right) {\mathsf j } + \left ( a_1 d_2 + a_2 d_1 + b_1 c_2 - c_1 b_2 \right) {\mathsf k }$    


An Alternate Representation for Quaternions

The expression for multiplication of quaternions, given above, is quite complex - and results in even worse complexity for the division and inverse formulas. The quaternions can be written in an different form - one which involves vectors - which dramatically simplifies the formulas. These expressions have become the preferred form for representing quaternions.

In this form, the quaternion $ {\mathsf q } \: = \: a + b {\mathsf i } + c {\mathsf j } + d {\mathsf k } $ is written as

$\displaystyle ( a, {\vec v })
$

where $ {\vec v }$ is the vector $ < b, c, d >$.

We can rewrite the addition formula for two quaternions $ {\mathsf q } _1 = ( a_1, {\vec v }_1 )$ and $ {\mathsf q } _2 = ( a_2, {\vec v }_2 )$ as

$\displaystyle {\mathsf q } _1 + {\mathsf q } _2 \: = \: ( a_1 + a_2, {\vec v }_1 + {\vec v }_2 )
$

and the product formula as

$\displaystyle {\mathsf q } _1 {\mathsf q } _2 \: = \: ( a_1 a_2 - {\vec v }_1 \...
...ec v }_2,
a_1 {\vec v }_2 + a_2 {\vec v }_1 + {\vec v }_1 \times {\vec v }_2 )
$

With some algebraic manipulation, these formulas can be shown to be identical with those of the $ {\mathsf i } $, $ {\mathsf j } $, $ {\mathsf k } $ representation. We note that the quaternions of the form $ (a,<0,0,0>)$ can be associated with the real numbers, and the quaternions of the form $ (a, <b,0,0>)$ can be associated with the complex numbers.


Properties of Quaternions

With this new representation, it is straightforward to develop a complete set of properties of quaternions.

Given the quaternions $ {\mathsf q } = ( a, {\vec v })$, $ {\mathsf q } _1 = ( a_1, {\vec v }_1 )$, and $ {\mathsf q } _2 = ( a_2, {\vec v }_2 )$, we can verify the following properties.


Notation

Quaternions of the form $ (a, {\vec 0 })$ are normally denoted in their real number form - as $ a$. this allows a scalar multiplication property to be given by

It also allows us to simplify some expressions. For example, the expression for the multiplicative inverse can now be written This also allows us to write the multiplicative identity of the quaternions as $ 1$ instead of $ (1, {\vec 0 })$, and the additive identity as 0.


The Quaternions are not Commutative under Multiplication

Whereas we can add, subtract, multiply and divide quaternions, we must always be aware of the order in which these operations are made. This is because quaternions do not commute under multiplication - in general $ {\mathsf q } _1 {\mathsf q } _2 \not = {\mathsf q } _2 {\mathsf q } _1$.

To give an example of this consider the two quaternions $ {\mathsf q } _1 =(1,<1,0,0>)$ and $ {\mathsf q } _2=(2,<0,1,0>)$. Multiplying these we obtain

$\displaystyle {\mathsf q } _1 {\mathsf q } _2 \: = \: ( 2 - 0, <0,1,0> + 2<1,0,0> + <0,0,1> )
\: = \: ( 2, <2,1,1> )
$

or

$\displaystyle {\mathsf q } _2 {\mathsf q } _1 \: = \: ( 2 - 0, 2<1,0,0> + <0,1,0> + <0,0,-1> )
\: = \: ( 2, <2,1,-1> )
$

and they are not equal. This is because the vector cross products give different results depending on the order of the vectors - in general, $ {\vec v }_1 \times {\vec v }_2 \not = {\vec v }_2 \times {\vec v }_1$.


Length of a Quaternion, Unit Quaternions

We define the length of a quaternion $ {\mathsf q } = (a, {\vec v })$ to be

$\displaystyle \vert {\mathsf q } \vert \: = \: \sqrt{a^2 + \vert {\vec v }\vert^2}
$

where $ \vert {\vec v }\vert$ is the length of the vector $ {\vec v }$. The unit quaternions are those that have length one.


Return to the Graphics Notes Home Page
Return to the Geometric Modeling Notes Home Page
Return to the UC Davis Visualization and Graphics Group Home Page


This document maintained by Ken Joy

Mail us your comments

All contents copyright (c) 1996, 1997, 1998, 1999
Computer Science Department
University of California, Davis

All rights reserved.


Ken Joy
1999-12-06