# Maths - Rotations using Matrix - Samples in 90 degree steps

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.

Heading applied first giving 4 possible orientations:

reference orientation

attitude = 0
bank = 0

 ch*ca -ch*sa*cb + sh*sb ch*sa*sb + sh*cb sa ca*cb -ca*sb -sh*ca sh*sa*cb + ch*sb - sh*sa*sb + ch*cb

ch=1
ca=1
cb=1
sh=0
sa=0
sb=0

 1 0 0 0 1 0 0 0 1

rotate by 90 degrees about y axis

heading = 90 degrees
attitude = 0
bank = 0

 ch*ca -ch*sa*cb + sh*sb ch*sa*sb + sh*cb sa ca*cb -ca*sb -sh*ca sh*sa*cb + ch*sb - sh*sa*sb + ch*cb

ch=0
ca=1
cb=1
sh=1
sa=0
sb=0

 0 0 1 0 1 0 -1 0 0

rotate by 180 degrees about y axis

heading = 180 degrees
attitude = 0
bank = 0

 ch*ca -ch*sa*cb + sh*sb ch*sa*sb + sh*cb sa ca*cb -ca*sb -sh*ca sh*sa*cb + ch*sb - sh*sa*sb + ch*cb

ch=-1
ca=1
cb=1
sh=0
sa=0
sb=0

 -1 0 0 0 1 0 0 0 -1

rotate by 270 degrees about y axis

heading = -90 degrees
attitude = 0
bank = 0

 ch*ca -ch*sa*cb + sh*sb ch*sa*sb + sh*cb sa ca*cb -ca*sb -sh*ca sh*sa*cb + ch*sb - sh*sa*sb + ch*cb

ch=0
ca=1
cb=1
sh=-1
sa=0
sb=0

 0 0 -1 0 1 0 1 0 0

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)

attitude = 90 degrees
bank = 0

 ch*ca -ch*sa*cb + sh*sb ch*sa*sb + sh*cb sa ca*cb -ca*sb -sh*ca sh*sa*cb + ch*sb - sh*sa*sb + ch*cb

ch=1
ca=0
cb=1
sh=0
sa=1
sb=0

 0 -1 0 1 0 0 0 0 1

heading = 90 degrees
attitude = 90 degrees
bank = 0

 ch*ca -ch*sa*cb + sh*sb ch*sa*sb + sh*cb sa ca*cb -ca*sb -sh*ca sh*sa*cb + ch*sb - sh*sa*sb + ch*cb

ch=0
ca=0
cb=1
sh=1
sa=1
sb=0

 0 0 1 1 0 0 0 1 0

heading = 180 degrees
attitude = 90 degrees
bank = 0

 ch*ca -ch*sa*cb + sh*sb ch*sa*sb + sh*cb sa ca*cb -ca*sb -sh*ca sh*sa*cb + ch*sb - sh*sa*sb + ch*cb

ch=-1
ca=0
cb=1
sh=0
sa=1
sb=0

 0 1 0 1 0 0 0 0 -1

heading = -90 degrees
attitude = 90 degrees
bank = 0

 ch*ca -ch*sa*cb + sh*sb ch*sa*sb + sh*cb sa ca*cb -ca*sb -sh*ca sh*sa*cb + ch*sb - sh*sa*sb + ch*cb

ch=0
ca=0
cb=1
sh=-1
sa=1
sb=0

 0 0 -1 1 0 0 0 -1 0

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

attitude = -90 degrees
bank = 0

 ch*ca -ch*sa*cb + sh*sb ch*sa*sb + sh*cb sa ca*cb -ca*sb -sh*ca sh*sa*cb + ch*sb - sh*sa*sb + ch*cb

ch=1
ca=0
cb=1
sh=0
sa=-1
sb=0

 0 1 0 -1 0 0 0 0 1

heading = 90 degrees
attitude = -90 degrees
bank = 0

 ch*ca -ch*sa*cb + sh*sb ch*sa*sb + sh*cb sa ca*cb -ca*sb -sh*ca sh*sa*cb + ch*sb - sh*sa*sb + ch*cb

ch=0
ca=0
cb=1
sh=1
sa=-1
sb=0

 0 0 1 -1 0 0 0 -1 0

heading = 180 degrees
attitude = -90 degrees
bank = 0

 ch*ca -ch*sa*cb + sh*sb ch*sa*sb + sh*cb sa ca*cb -ca*sb -sh*ca sh*sa*cb + ch*sb - sh*sa*sb + ch*cb

ch=-1
ca=0
cb=1
sh=0
sa=-1
sb=0

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

heading = -90 degrees
attitude = -90 degrees
bank = 0

 ch*ca -ch*sa*cb + sh*sb ch*sa*sb + sh*cb sa ca*cb -ca*sb -sh*ca sh*sa*cb + ch*sb - sh*sa*sb + ch*cb

ch=0
ca=0
cb=1
sh=-1
sa=-1
sb=0

 0 0 -1 -1 0 0 0 1 0

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

attitude = 0
bank = 90 degrees

 ch*ca -ch*sa*cb + sh*sb ch*sa*sb + sh*cb sa ca*cb -ca*sb -sh*ca sh*sa*cb + ch*sb - sh*sa*sb + ch*cb

ch=1
ca=1
cb=0
sh=0
sa=0
sb=1

 1 0 0 0 0 -1 0 1 0

heading = 90 degrees
attitude = 0
bank = 90 degrees

 ch*ca -ch*sa*cb + sh*sb ch*sa*sb + sh*cb sa ca*cb -ca*sb -sh*ca sh*sa*cb + ch*sb - sh*sa*sb + ch*cb

ch=0
ca=1
cb=0
sh=1
sa=0
sb=1

 0 1 0 0 0 -1 -1 0 0

heading = 180 degrees
attitude = 0
bank = 90 degrees

 ch*ca -ch*sa*cb + sh*sb ch*sa*sb + sh*cb sa ca*cb -ca*sb -sh*ca sh*sa*cb + ch*sb - sh*sa*sb + ch*cb

ch=-1
ca=1
cb=0
sh=0
sa=0
sb=1

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

heading = -90 degrees
attitude = 0
bank = 90 degrees

 ch*ca -ch*sa*cb + sh*sb ch*sa*sb + sh*cb sa ca*cb -ca*sb -sh*ca sh*sa*cb + ch*sb - sh*sa*sb + ch*cb

ch=0
ca=1
cb=0
sh=-1
sa=0
sb=1

 0 -1 0 0 0 -1 1 0 0

Apply bank +180 degrees:

attitude = 0
bank = 180 degrees

 ch*ca -ch*sa*cb + sh*sb ch*sa*sb + sh*cb sa ca*cb -ca*sb -sh*ca sh*sa*cb + ch*sb - sh*sa*sb + ch*cb

ch=1
ca=1
cb=-1
sh=0
sa=0
sb=0

 1 0 0 0 -1 0 0 0 -1

heading = 90 degrees
attitude = 0
bank = 180 degrees

 ch*ca -ch*sa*cb + sh*sb ch*sa*sb + sh*cb sa ca*cb -ca*sb -sh*ca sh*sa*cb + ch*sb - sh*sa*sb + ch*cb

ch=0
ca=1
cb=-1
sh=1
sa=0
sb=0

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

heading = 180 degrees
attitude = 0
bank = 180 degrees

 ch*ca -ch*sa*cb + sh*sb ch*sa*sb + sh*cb sa ca*cb -ca*sb -sh*ca sh*sa*cb + ch*sb - sh*sa*sb + ch*cb

ch=-1
ca=1
cb=-1
sh=0
sa=0
sb=0

 -1 0 0 0 -1 0 0 0 1

heading = -90 degrees
attitude = 0
bank = 180 degrees

 ch*ca -ch*sa*cb + sh*sb ch*sa*sb + sh*cb sa ca*cb -ca*sb -sh*ca sh*sa*cb + ch*sb - sh*sa*sb + ch*cb

ch=0
ca=1
cb=-1
sh=-1
sa=0
sb=0

 0 0 1 0 -1 0 1 0 0

Apply bank -90 degrees:

attitude = 0
bank = -90 degrees

 ch*ca -ch*sa*cb + sh*sb ch*sa*sb + sh*cb sa ca*cb -ca*sb -sh*ca sh*sa*cb + ch*sb - sh*sa*sb + ch*cb

ch=1
ca=1
cb=0
sh=0
sa=0
sb=-1

 1 0 0 0 0 1 0 -1 0

heading = 90 degrees
attitude = 0
bank = -90 degrees

 ch*ca -ch*sa*cb + sh*sb ch*sa*sb + sh*cb sa ca*cb -ca*sb -sh*ca sh*sa*cb + ch*sb - sh*sa*sb + ch*cb

ch=0
ca=1
cb=0
sh=1
sa=0
sb=-1

 0 -1 0 0 0 1 -1 0 0

heading = 180 degrees
attitude = 0
bank = -90 degrees

 ch*ca -ch*sa*cb + sh*sb ch*sa*sb + sh*cb sa ca*cb -ca*sb -sh*ca sh*sa*cb + ch*sb - sh*sa*sb + ch*cb

ch=-1
ca=1
cb=0
sh=0
sa=0
sb=-1

 -1 0 0 0 0 1 0 1 0

heading = -90 degrees
attitude = 0
bank = -90 degrees

 ch*ca -ch*sa*cb + sh*sb ch*sa*sb + sh*cb sa ca*cb -ca*sb -sh*ca sh*sa*cb + ch*sb - sh*sa*sb + ch*cb

ch=0
ca=1
cb=0
sh=-1
sa=0
sb=-1

 0 1 0 0 0 1 1 0 0

reference orientation

 1 0 0 0 1 0 0 0 1

rotate by 90 degrees about x axis

 1 0 0 0 0 -1 0 1 0

rotate by 180 degrees about x axis

 1 0 0 0 -1 0 0 0 -1

rotate by 270 degrees about x axis

 1 0 0 0 0 1 0 -1 0

rotate by 90 degrees about z axis

 0 1 0 -1 0 0 0 0 1

rotate by 90 degrees about y axis

 0 0 -1 0 1 0 1 0 0

rotate by 180 degrees about z axis

 -1 0 0 0 -1 0 0 0 1

rotate by 180 degrees about y axis

 -1 0 0 0 1 0 0 0 -1

rotate by 270 degrees about z axis

 0 -1 0 1 0 0 0 0 1

rotate by 270 degrees about y axis

 0 0 1 0 1 0 -1 0 0

When we combine these rotations about the x,y and z axies in 90 degree multiples there are 24 possible orientations as shown here:

 1 0 0 0 1 0 0 0 1

 1 0 0 0 0 -1 0 1 0

 1 0 0 0 -1 0 0 0 -1

 1 0 0 0 0 1 0 -1 0

 0 -1 0 1 0 0 0 0 1

 0 0 1 1 0 0 0 1 0

 0 1 0 1 0 0 0 0 -1

 0 0 -1 1 0 0 0 -1 0

 -1 0 0 0 -1 0 0 0 1

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

 -1 0 0 0 1 0 0 0 -1

 -1 0 0 0 0 1 0 1 0

 0 1 0 -1 0 0 0 0 1

 0 0 1 -1 0 0 0 -1 0

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

 0 0 -1 -1 0 0 0 1 0

 0 0 -1 0 1 0 1 0 0

 0 1 0 0 0 1 1 0 0

 0 0 1 0 -1 0 1 0 0

 0 -1 0 0 0 -1 1 0 0

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

 0 -1 0 0 0 1 -1 0 0

 0 0 1 0 1 0 -1 0 0

 0 1 0 0 0 -1 -1 0 0

encoding of these rotations in quaternions is shown here.
encoding of these rotations in axis-angle is shown here.
encoding of these rotations in euler angles is shown here.