Monday 30 June 2014

Tip for Quaternion Multiplication by Hand

Here is a technique for multiplying two quaternions by hand so you do not have to remember the formula mentioned in my introduction to quaternions post [link].

If you are multiplying P x Q where P and Q are two quaternions create a grid as shown below.

Write the first quaternion of the multiplication in a column on the left side of the grid and then write the second quaternion in a row at the top of the grid.

Grid


At the intersection of each row and column, write the multiplication of the two parts of the quaternions that are at the start of a row and the top of a column remembering to write the P part first.

Whenever a quaternion part is zero write zero in the entire row or column since zero times anything is zero.

Now replace the letter times letter multiplications at each intersection.
If the letters are the same, replace them with –1
If the letters are different, replace them with a single letter according to the following rules.
  • i x j = k
  • i x k = –j
  • j x i = –k
  • j x k = i
  • k x i = j
  • k x j = –i
One way to remember these rules is to draw a circle with the letters i, j, k as shown below.

circle

Find the first letter of the multiplication in the circle and then move in the circle to the second letter of the multiplication.

The result of the multiplication is the next letter in the circle in the same direction you moved.

If you moved in a counter-clockwise direction the result is positive.

If you moved in a clockwise direction, change the sign of the third letter to negative.


If you are familiar with the vector cross product you can use another trick to remember the rules.

Draw a right handed coordinate system with the axes marked i, j and k as shown below.

cross product

Then cross the first letter’s axis into the second letter’s axis with your right hand.

The letter of the axis direction your thumb points in is the letter the multiplication equals.

If your thumb points in the negative axis direction the sign of the letter is negative.

Once you have replaced all the letter x letter multiplications, add up all the numbers multiplied by i to get the i part of the quaternion.

Add up all the j parts to get the j part.

Add up all the k parts to the k part.

Add up all the real number parts to get the real number part.

Here is a worked example.

First calculate your quaternions and set up the grid.

Quaternion multiplication grid

Next mark the columns and rows with zero if any part of the either quaternion is zero.

Quaternion multiplication mark zero

Next write the multiplication of the parts at the row/column intersections in the order P part first.

Quaternion multiplication multiply parts

Next resolve the multiplications at the row/column intersections by multiplying the numbers together and then replacing the letter multiplications according to the rules.

Here only i x j was replaced with k.

Quaternion multiplication replace letters

Add up all the multiplications that include i to get the new i part of the quaternion.

Quaternion multiplication add all i

Add up all the multiplications that include j to get the new j part of the quaternion.

Quaternion multiplication add all j

Add up all the multiplications that include k to get the new k part of the quaternion.

Quaternion multiplication add all k

And finally add up all the numbers to get the real part of the quaternion and you have the resultant quaternion.

Quaternion multiplication add all reals



No comments:

Post a Comment