Within Qinsy certain rotation matrices are used for object reference frameand .
HPR Rotation Sequence
Internally, Qinsy uses the so-called 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 Z-axis), then the Pitch (around the rotated X-axis), and then the Roll (around the rotated Y-axis).
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 = RT · PT · HT · 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 non-moving 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 Z-axis
The rotation matrix to rotate an offset vector in the object reference frame by a Heading angle around the Z-axis is given by:
Whereby Heading angle H is positive if the object is rotating to starboard (turning clockwise).
Pitch Rotation around X-axis
The rotation matrix to rotate an offset vector in the object reference frame by a Pitch angle around the X-axis is given by:
Whereby Pitch angle P is positive when the object bow moves upwards.
Roll Rotation around Y-axis
The rotation matrix to rotate an offset vector in the object reference frame by a Roll angle around the Y-axis is given by:
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:
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. x-y-z, or x-y’-z″). Proper Euler angles use the same axis for both the first and third elemental rotations (e.g., z-x-z, or z-x’-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, cross-terms will occur if the wrong rotation matrix is used.
The combined rotation matrix in case of the HRP sequence of rotation matrices is:
For example, if the HPR matrix is used with Heading 90°, Pitch 30°, Roll 30°, then a unit vector in the direction of the Z-axis in the body frame will be rotated to:
If the HRP matrix is used with the same Heading 90°, Pitch 30°, Roll 30°, then a unit vector in the direction of the Z-axis in the body frame would be rotated to:
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:
In case the Pitch and Roll angles are smaller, 3° instead of 30°, the differences become much smaller:
In case the Pitch and Roll angles are even smaller, 0.3° instead of 3.0°, the differences are neglegible: