Howto QINSy Rotation Matrices
Within QINSy certain rotation matrices are used for object reference frame offsets and attitude angles and rotation offsets.
Rotation Matrices:
HPR Rotation Sequence
Internally, QINSy uses the socalled HPR sequence of rotation matrices to rotate an offset vector x in the object reference frame (body coordinates) to an offset vector x' in the local level reference frame (world coordinates), where H denotes the Heading matrix, P is the Pitch matrix, and R is the Roll matrix:
x' = H · P · R · x
Heading, pitch and roll angles are measured about the local level reference frame axes. When seen from outside the object, first the Heading is applied (around the Zaxis), then the Pitch (around the rotated Xaxis), and then the Roll (around the rotated Yaxis).
In order to rotate an offset vector x' in the local level reference frame to an offset vector x in the object reference frame, the transpose of the above equations would be required as:
x = R^{T} · P^{T} · H^{T} · x'
For rotation matrices holds that the transpose matrix is equal to the inverse matrix, i.e. the rotation matrix using the negative angle.
In literature, the HPR sequence is often called the YPR method when describing the principal axes of an aircraft. In that case, heading is the direction that the aircraft's nose is pointing. The matrix of the composed rotations is M = Yaw·Pitch·Roll. Of the six possible combinations of Yaw, Pitch and Roll, this combination is the only one in which the Heading (direction of the Roll axis) is equal to one of the rotations (the Yaw) and the Elevation (angle of the Roll axis with the horizontal plane) is equal to one other of the rotations (to the Pitch).
The HPR rotation sequence about the original set of nonmoving reference axes can be explained in terms of the Euler angle rotation sequence about the moving set of body axes via the following relationship: three angle rotations in the sequence ijk taken about the reference axes results in the same net orientation as performing the same three rotations but in the sequence kji about the moving axes.
Heading Rotation around Zaxis
The rotation matrix to rotate an offset vector in the object reference frame by a Heading angle around the Zaxis is given by:
[ x ]' [ cos(H) , sin(H) , 0 ] [ x ]
[ y ] = [ sin(H) , cos(H) , 0 ] * [ y ]
[ z ] [ 0 , 0 , 1 ] [ z ]
Whereby Heading angle H is positive if the object is rotating to starboard (turning clockwise).
Pitch Rotation around Xaxis
The rotation matrix to rotate an offset vector in the object reference frame by a Pitch angle around the Xaxis is given by:
[ x ]' [ 1 , 0 , 0 ] [ x ]
[ y ] = [ 0 , cos(P) , sin(P) ] * [ y ]
[ z ] [ 0 , sin(P) , cos(P) ] [ z ]
Whereby Pitch angle P is positive when the object bow moves upwards.
Roll Rotation around Yaxis
The rotation matrix to rotate an offset vector in the object reference frame by a Roll angle around the Yaxis is given by:
[ x ]' [ cos(R) , 0 , sin(R) ] [ x ]
[ y ] = [ 0 , 1 , 0 ] * [ y ]
[ z ] [ sin(R) , 0 , cos(R) ] [ z ]
Whereby Roll angle R is positive if the object is heeling to starboard.
HPR Rotation Matrix
The combined rotation matrix in case of the HPR sequence of rotation matrices is:
[ x ]' [ cos(H)*cos(R)+sin(H)*sin(P)*sin(R) , sin(H)*cos(P) , cos(H)*sin(R)sin(H)*sin(P)*cos(R) ] [ x ]
[ y ] = [ sin(H)*cos(R)+cos(H)*sin(P)*sin(R) , cos(H)*cos(P) , sin(H)*sin(R)cos(H)*sin(P)*cos(R) ] * [ y ]
[ z ] [ cos(P)*sin(R) , sin(P) , cos(P)*cos(R) ] [ z ]
HRP Rotation Sequence
There are six possibilities of choosing the rotation axes for the Yaw, Pitch and Roll angles if we consider that they are Tait–Bryan angles representing rotations about three distinct axes (e.g. xyz, or xy’z″). Proper Euler angles use the same axis for both the first and third elemental rotations (e.g., zxz, or zx’z″).
In navigation, Yaw (Heading) is never applied as the second rotation, so HPR, HRP, RPH and PRH are the only valid combinations encountered. The QINSy Database Setup Program contains an option to convert rotation angles between these 4 rotation sequences.
Some motion sensors output Pitch and Roll angles that should be applied in the HRP rotation sequence. It is important to select the proper rotation angle type, since the order of the applying the individual rotation matrices is important. In case the Pitch and Roll angles are not small, crossterms will occur if the wrong rotation matrix is used.
The combined rotation matrix in case of the HRP sequence of rotation matrices is:
[ x ]' [ cos(H)*cos(R) , sin(H)*cos(P)+cos(H)*sin(R)*sin(P) , sin(H)*sin(P)+cos(H)*sin(R)*cos(P) ] [ x ]
[ y ] = [ sin(H)*cos(R) , cos(H)*cos(P)sin(H)*sin(R)*sin(P) , cos(H)*sin(P)sin(H)*sin(R)*cos(P) ] * [ y ]
[ z ] [ sin(R) , cos(R)*sin(P) , cos(R)*cos(P) ] [ z ]
For example, if the HPR matrix is used with Heading 90°, Pitch 30°, Roll 30°, then a unit vector in the direction of the Zaxis in the body frame will be rotated to:
[ 0.433 ] [ 0.000 ]
[ 0.500 ] = H(90.000) * P(30.000) * R(30.000) * [ 0.000 ]
[ 0.750 ] [ 1.000 ]
If the HRP matrix is used with the same Heading 90°, Pitch 30°, Roll 30°, then a unit vector in the direction of the Zaxis in the body frame would be rotated to:
[ 0.500 ] [ 0.000 ]
[ 0.433 ] = H(90.000) * R(30.000) * P(30.000) * [ 0.000 ]
[ 0.750 ] [ 1.000 ]
Instead, the HRP matrix should be used with Heading 73.898°, Pitch 33.690°, Roll 25.659°, in order to obtain the same result for the rotation of the unit vector:
[ 0.433 ] [ 0.000 ]
[ 0.500 ] = H(73.898) * R(33.690) * P(25.659) * [ 0.000 ]
[ 0.750 ] [ 1.000 ]
In case the Pitch and Roll angles are smaller, 3° instead of 30°, the differences become much smaller:
[ 0.052 ] [ 0.000 ]
[ 0.052 ] = H(90.000) * P( 3.000) * R( 3.000) * [ 0.000 ]
[ 0.997 ] [ 1.000 ]
[ 0.052 ] [ 0.000 ]
[ 0.052 ] = H(89.843) * R( 3.004) * P( 2.996) * [ 0.000 ]
[ 0.997 ] [ 1.000 ]
In case the Pitch and Roll angles are even smaller, 0.3° instead of 3.0°, the differences are neglegible:
[ 0.005 ] [ 0.000 ]
[ 0.005 ] = H(90.000) * P( 0.300) * R( 0.300) * [ 0.000 ]
[ 1.000 ] [ 1.000 ]
[ 0.005 ] [ 0.000 ]
[ 0.005 ] = H(90.000) * R( 0.300) * P( 0.300) * [ 0.000 ]
[ 1.000 ] [ 1.000 ]
Related articles

Howto QINSy Sign Conventions (Qinsy)

Howto QINSy Rotation Matrices (Qinsy)