Maths - Matrix to Quaternion - Sample Orientations

Sample Rotations

In order to try to explain things and give some examples we can try I thought it might help to show the rotations for a finite subset of the rotation group. We will use the set of rotations of a cube onto itself, this is a permutation group which gives 24 possible rotations as explaned on this page.

In the following table we will need to know what quadrant the results are in, so I have taken some sample results from Math.atan2

atan2(0.0,0.0)=0.0 (although Math.atan2 returns 0 this is abitary and if both x and y is zero we need to find some other way to get to value)
atan2(0.0,1.0)=0.0
atan2(1.0,1.0)=0.7853981633974483
atan2(1.0,0.0)=1.5707963267948966
atan2(1.0,-1.0)=2.356194490192345
atan2(0.0,-1.0)=3.141592653589793
atan2(-1.0,-1.0)=-2.356194490192345
atan2(-1.0,0.0)=-1.5707963267948966
atan2(-1.0,1.0)=-0.7853981633974483
heading applied first giving 4 possible orientations:

right

reference orientation

1 0 0
0 1 0
0 0 1

trace = m00 + m11 + m22 + 1 = 4

so use:

  • qw= sqrt (1 + m00 + m11 + m22) /2
  • qx = (m21 - m12)/( 4 *qw)
  • qy = (m02 - m20)/( 4 *qw)
  • qz = (m10 - m01)/( 4 *qw)

q = 1

back

rotate by 90 degrees about y axis

0 0 1
0 1 0
-1 0 0

trace = m00 + m11 + m22 + 1 = 2

so use:

  • qw= sqrt (1 + m00 + m11 + m22) /2
  • qx = (m21 - m12)/( 4 *qw)
  • qy = (m02 - m20)/( 4 *qw)
  • qz = (m10 - m01)/( 4 *qw)

q = 0.7071 + j 0.7071

left

rotate by 180 degrees about y axis

-1 0 0
0 1 0
0 0 -1

trace = m00 + m11 + m22 + 1 = 0

so this may not be accurate:

  • qw= sqrt (1 + m00 + m11 + m22) /2
  • qx = (m21 - m12)/( 4 *qw)
  • qy = (m02 - m20)/( 4 *qw)
  • qz = (m10 - m01)/( 4 *qw)

q = j

forward

rotate by 270 degrees about y axis

0 0 -1
0 1 0
1 0 0


trace = m00 + m11 + m22 + 1 = 2

so use:

  • qw= sqrt (1 + m00 + m11 + m22) /2
  • qx = (m21 - m12)/( 4 *qw)
  • qy = (m02 - m20)/( 4 *qw)
  • qz = (m10 - m01)/( 4 *qw)

q = 0.7071 - j 0.7071

(equivilant rotation to:
-0.7071 + j 0.7071)

Then apply attitude +90 degrees for each of the above: (note: that if we went on to apply bank to these it would just rotate between these values, the straight up and streight down orientations are known as singularities because they can be fully defined without using the bank value)

up

0 -1 0
1 0 0
0 0 1

trace = m00 + m11 + m22 + 1 = 2

so use:

  • qw= sqrt (1 + m00 + m11 + m22) /2
  • qx = (m21 - m12)/( 4 *qw)
  • qy = (m02 - m20)/( 4 *qw)
  • qz = (m10 - m01)/( 4 *qw)

q = 0.7071 + k 0.7071

 

 

up

0 0 1
1 0 0
0 1 0

trace = m00 + m11 + m22 + 1 = 1

so use:

  • qw= sqrt (1 + m00 + m11 + m22) /2
  • qx = (m21 - m12)/( 4 *qw)
  • qy = (m02 - m20)/( 4 *qw)
  • qz = (m10 - m01)/( 4 *qw)

q = 0.5 + i 0.5 + j 0.5 + k 0.5

 

 

up

0 1 0
1 0 0
0 0 -1

trace = m00 + m11 + m22 + 1 = 0

so this may not be accurate:

  • qw= sqrt (1 + m00 + m11 + m22) /2 =0
  • qx = (m21 - m12)/( 4 *qw) gives divide by zero
  • qy = (m02 - m20)/( 4 *qw)
  • qz = (m10 - m01)/( 4 *qw)

q = i 0.7071 +j 0.7071

 

up

0 0 -1
1 0 0
0 -1 0

trace = m00 + m11 + m22 + 1 = 1

so use:


  • qw= sqrt (1 + m00 + m11 + m22) /2
  • qx = (m21 - m12)/( 4 *qw)
  • qy = (m02 - m20)/( 4 *qw)
  • qz = (m10 - m01)/( 4 *qw)

q = 0.5 - i 0.5 - j 0.5 + k 0.5

 

 

Or instead apply attitude -90 degrees (also a singularity):

down

0 1 0
-1 0 0
0 0 1

trace = m00 + m11 + m22 + 1 = 2

so use:

  • qw= sqrt (1 + m00 + m11 + m22) /2
  • qx = (m21 - m12)/( 4 *qw)
  • qy = (m02 - m20)/( 4 *qw)
  • qz = (m10 - m01)/( 4 *qw)

q = 0.7071 - k 0.7071

(equivilant rotation to:
-0.7071 + k 0.7071)

down

0 0 1
-1 0 0
0 -1 0


trace = m00 + m11 + m22 + 1 = 1

so use:

  • qw= sqrt (1 + m00 + m11 + m22) /2
  • qx = (m21 - m12)/( 4 *qw)
  • qy = (m02 - m20)/( 4 *qw)
  • qz = (m10 - m01)/( 4 *qw)


q = 0.5 - i 0.5 + j 0.5 - k 0.5

down

0 -1 0
-1 0 0
0 0 -1

trace = m00 + m11 + m22 + 1 = 0

so this may not be accurate:


  • qw= sqrt (1 + m00 + m11 + m22) /2
  • qx = (m21 - m12)/( 4 *qw)
  • qy = (m02 - m20)/( 4 *qw)
  • qz = (m10 - m01)/( 4 *qw)

q = -i 0.7071 + j 0.7071

(equivilant rotation to:
i 0.7071 - j 0.7071)

down

0 0 -1
-1 0 0
0 1 0

trace = m00 + m11 + m22 + 1 = 1

so use:

  • qw= sqrt (1 + m00 + m11 + m22) /2
  • qx = (m21 - m12)/( 4 *qw)
  • qy = (m02 - m20)/( 4 *qw)
  • qz = (m10 - m01)/( 4 *qw)


q = 0.5 + i 0.5 - j 0.5 - k 0.5

Normally we dont go beond attitude + or - 90 degrees because thes are singularities, instead apply bank +90 degrees:

right

1 0 0
0 0 -1
0 1 0

trace = m00 + m11 + m22 + 1 = 2

so use:

  • qw= sqrt (1 + m00 + m11 + m22) /2
  • qx = (m21 - m12)/( 4 *qw)
  • qy = (m02 - m20)/( 4 *qw)
  • qz = (m10 - m01)/( 4 *qw)

q = 0.7071 + i 0.7071

 

 

back

0 1 0
0 0 -1
-1 0 0

trace = m00 + m11 + m22 + 1 = 1

so use:

  • qw= sqrt (1 + m00 + m11 + m22) /2
  • qx = (m21 - m12)/( 4 *qw)
  • qy = (m02 - m20)/( 4 *qw)
  • qz = (m10 - m01)/( 4 *qw)

q = 0.5 + i 0.5 + j 0.5 - k 0.5

 

left

-1 0 0
0 0 -1
0 -1 0

trace = m00 + m11 + m22 + 1 = 0

so this may not be accurate:

  • qw= sqrt (1 + m00 + m11 + m22) /2
  • qx = (m21 - m12)/( 4 *qw)
  • qy = (m02 - m20)/( 4 *qw)
  • qz = (m10 - m01)/( 4 *qw)

q = j 0.7071 - k 0.7071

 

forward

0 -1 0
0 0 -1
1 0 0

trace = m00 + m11 + m22 + 1 = 1

so use:

  • qw= sqrt (1 + m00 + m11 + m22) /2
  • qx = (m21 - m12)/( 4 *qw)
  • qy = (m02 - m20)/( 4 *qw)
  • qz = (m10 - m01)/( 4 *qw)

q = 0.5 + i 0.5 - j 0.5 + k 0.5

 

Apply bank +180 degrees:

right

1 0 0
0 -1 0
0 0 -1

trace = m00 + m11 + m22 + 1 = 0

so this may not be accurate:

  • qw= sqrt (1 + m00 + m11 + m22) /2
  • qx = (m21 - m12)/( 4 *qw)
  • qy = (m02 - m20)/( 4 *qw)
  • qz = (m10 - m01)/( 4 *qw)

q = i

back

0 0 -1
0 -1 0
-1 0 0

trace = m00 + m11 + m22 + 1 = 0

so this may not be accurate:

  • qw= sqrt (1 + m00 + m11 + m22) /2
  • qx = (m21 - m12)/( 4 *qw)
  • qy = (m02 - m20)/( 4 *qw)
  • qz = (m10 - m01)/( 4 *qw)

q = i 0.7071 - k 0.7071

 

left

-1 0 0
0 -1 0
0 0 1

trace = m00 + m11 + m22 + 1 = 0

so this may not be accurate:

  • qw= sqrt (1 + m00 + m11 + m22) /2
  • qx = (m21 - m12)/( 4 *qw)
  • qy = (m02 - m20)/( 4 *qw)
  • qz = (m10 - m01)/( 4 *qw)

q = k

forward

0 0 1
0 -1 0
1 0 0

trace = m00 + m11 + m22 + 1 = 0

so this may not be accurate:

  • qw= sqrt (1 + m00 + m11 + m22) /2
  • qx = (m21 - m12)/( 4 *qw)
  • qy = (m02 - m20)/( 4 *qw)
  • qz = (m10 - m01)/( 4 *qw)

q = i 0.7071 + k 0.7071

 

Apply bank -90 degrees:

right

1 0 0
0 0 1
0 -1 0

trace = m00 + m11 + m22 + 1 = 2

so use:

  • qw= sqrt (1 + m00 + m11 + m22) /2
  • qx = (m21 - m12)/( 4 *qw)
  • qy = (m02 - m20)/( 4 *qw)
  • qz = (m10 - m01)/( 4 *qw)

q = 0.7071 - i 0.7071

(equivilant rotation to:
-0.7071 + i 0.7071)

 

back

0 -1 0
0 0 1
-1 0 0

trace = m00 + m11 + m22 + 1 = 1

so use:

  • qw= sqrt (1 + m00 + m11 + m22) /2
  • qx = (m21 - m12)/( 4 *qw)
  • qy = (m02 - m20)/( 4 *qw)
  • qz = (m10 - m01)/( 4 *qw)

q = 0.5 - i 0.5 + j 0.5 + k 0.5

 

left

-1 0 0
0 0 1
0 1 0

trace = m00 + m11 + m22 + 1 = 0

so this may not be accurate:

  • qw= sqrt (1 + m00 + m11 + m22) /2
  • qx = (m21 - m12)/( 4 *qw)
  • qy = (m02 - m20)/( 4 *qw)
  • qz = (m10 - m01)/( 4 *qw)

q = j 0.7071 + k 0.7071

 

 

forward

0 1 0
0 0 1
1 0 0

trace = m00 + m11 + m22 + 1 = 1

so use:

  • qw= sqrt (1 + m00 + m11 + m22) /2
  • qx = (m21 - m12)/( 4 *qw)
  • qy = (m02 - m20)/( 4 *qw)
  • qz = (m10 - m01)/( 4 *qw)

q = 0.5 - i 0.5 - j 0.5 - k 0.5

 


metadata block
see also:

 

Correspondence about this page

Book Shop - Further reading.

Where I can, I have put links to Amazon for books that are relevant to the subject, click on the appropriate country flag to get more details of the book or to buy it from them.

cover us uk de jp fr caVisualizing Quaternions by Andrew J. Hanson

Other Math Books

This site may have errors. Don't use for critical systems.

Copyright (c) 1998-2023 Martin John Baker - All rights reserved - privacy policy.