c4dynamics.states.lib.rigidbody.rigidbody.BR

Contents

c4dynamics.states.lib.rigidbody.rigidbody.BR#

property rigidbody.BR#

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

Based on the current Euler angles, BR returns the DCM in a 3-2-1 order, i.e. first rotation about the z axis (yaw, \(\psi\)), then a rotation about the y axis (pitch, \(\theta\)), and finally a rotation about the x axis (roll, \(\varphi\)).

The DCM321 matrix is calculated by the rotmat module and is given by:

\[\begin{split}R = \begin{bmatrix} c\theta \cdot c\psi & c\theta \cdot s\psi & -s\theta \\ s\varphi \cdot s\theta \cdot c\psi - c\varphi \cdot s\psi & s\varphi \cdot s\theta \cdot s\psi + c\varphi \cdot c\psi & s\varphi \cdot c\theta \\ c\varphi \cdot s\theta \cdot c\psi + s\varphi \cdot s\psi & c\varphi \cdot s\theta \cdot s\psi - s\varphi \cdot c\psi & c\varphi \cdot c\theta \end{bmatrix}\end{split}\]

where

  • \(c\varphi \equiv cos(\varphi)\)

  • \(s\varphi \equiv sin(\varphi)\)

  • \(c\theta \equiv cos(\theta)\)

  • \(s\theta \equiv sin(\theta)\)

  • \(c\psi \equiv cos(\psi)\)

  • \(s\psi \equiv sin(\psi)\)

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]
>>> rb = c4d.rigidbody(psi = 45 * c4d.d2r)
>>> v_body = rb.BR @ v_inertial
>>> v_body  
[0.707  -0.707  0.0]