Main Content

Convert direction cosine matrix to quaternion vector

**Library:**Aerospace Blockset / Utilities / Axes Transformations

The Direction Cosine Matrix to Quaternions block transforms a
3-by-3 direction cosine matrix (DCM) into a four-element unit quaternion vector
(*q*_{0},
*q*_{1},
*q*_{2},
*q*_{3}). Aerospace Blockset™ uses quaternions that are defined using the scalar-first convention. The
DCM performs the coordinate transformation of a vector in inertial axes to a vector in
body axes. For more information on the direction cosine matrix, see Algorithms.

The DCM is defined as a function of a unit quaternion vector by the following:

$$DCM=\left[\begin{array}{ccc}({q}_{0}^{2}+{q}_{1}^{2}-{q}_{2}^{2}-{q}_{3}^{2})& 2({q}_{1}{q}_{2}+{q}_{0}{q}_{3})& 2({q}_{1}{q}_{3}-{q}_{0}{q}_{2})\\ 2({q}_{1}{q}_{2}-{q}_{0}{q}_{3})& ({q}_{0}^{2}-{q}_{1}^{2}+{q}_{2}^{2}-{q}_{3}^{2})& 2({q}_{2}{q}_{3}+{q}_{0}{q}_{1})\\ 2({q}_{1}{q}_{3}+{q}_{0}{q}_{2})& 2({q}_{2}{q}_{3}-{q}_{0}{q}_{1})& ({q}_{0}^{2}-{q}_{1}^{2}-{q}_{2}^{2}+{q}_{3}^{2})\end{array}\right]$$

Using this representation of the DCM, a number of calculations arrive at the correct quaternion. The first of these is to calculate the trace of the DCM to determine which algorithms are used. If the trace is greater than zero, the quaternion can be automatically calculated. When the trace is less than or equal to zero, the major diagonal element of the DCM with the greatest value must be identified to determine the final algorithm used to calculate the quaternion. Once the major diagonal element is identified, the quaternion is calculated.

Direction Cosine Matrix to Rotation Angles | Rotation Angles to Direction Cosine Matrix | Rotation Angles to Quaternions | Quaternions to Direction Cosine Matrix | Quaternions to Rotation Angles