c4dynamics.states.lib.quatbody.quatbody.RB

Contents

c4dynamics.states.lib.quatbody.quatbody.RB#

property quatbody.RB#

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

Based on the current attitude quaternion, RB returns the transpose matrix of BR, where BR is the Body from Reference DCM:

\[\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}\]

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

Returns:

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

Example

>>> v_body = [np.sqrt(3), 0, 1]
>>> qb = c4d.quatbody(theta = 30 * c4d.d2r)
>>> v_inertial = qb.RB @ v_body
>>> v_inertial   
[2.0  0.0  0.0]