c4dynamics.states.lib.quatbody.quatbody.BR

Contents

c4dynamics.states.lib.quatbody.quatbody.BR#

property quatbody.BR#

Returns a Body-from-Reference Direction Cosine Matrix (DCM).

Based on the current attitude quaternion \([q_w, q_x, q_y, q_z]\), BR returns the DCM that is calculated by the quat2dcm function and is given by:

\[\begin{split}R = \begin{bmatrix} 1 - 2(q_y^2 + q_z^2) & 2(q_x q_y + q_w q_z) & 2(q_x q_z - q_w q_y) \\ 2(q_x q_y - q_w q_z) & 1 - 2(q_x^2 + q_z^2) & 2(q_y q_z + q_w q_x) \\ 2(q_x q_z + q_w q_y) & 2(q_y q_z - q_w q_x) & 1 - 2(q_x^2 + q_y^2) \end{bmatrix}\end{split}\]

The matrix is identical to the DCM in a 3-2-1 order (dcm321) of the same attitude.

For the background material regarding the rotational matrix operations, see rotmat.

Returns:

out (numpy.ndarray) – A 3x3 DCM matrix uses to rotate a vector to the body frame from a reference frame of coordinates.

Example

>>> v_inertial = [1, 0, 0]
>>> qb = c4d.quatbody(psi = 45 * c4d.d2r)
>>> v_body = qb.BR @ v_inertial
>>> v_body  
[0.707  -0.707  0.0]