# Direction Cosines to Euler Angles (G Dataflow)

Converts a 3-by-3 matrix of direction cosines into Euler angles.  ## direction cosines

A 3-by-3 direction cosine matrix.

If rotation type is Passive and Intrinsic or Passive and Extrinsic, the matrix maps points in the old coordinate frame to points in the new coordinate frame. If rotation type is Active, the matrix maps the coordinates of the original points to the coordinates of the rotated points. Each element must be in the range of [-1, 1]. ## rotation order

Order of the axes to rotate the coordinates around.

Name Value Description
X-Y-Z 0 The first, second, and third rotations are about the x-, y-, and z-axes, respectively.
X-Z-Y 1 The first, second, and third rotations are about the x-, z-, and y-axes, respectively.
Y-X-Z 2 The first, second, and third rotations are about the y-, x-, and z-axes, respectively.
Y-Z-X 3 The first, second, and third rotations are about the y-, z-, and x-axes, respectively.
Z-X-Y 4 The first, second, and third rotations are about the z-, x-, and y-axes, respectively.
Z-Y-X 5 The first, second, and third rotations are about the z-, y-, and x-axes, respectively.
X-Y-X 6 The first, second, and third rotations are about the x-, y-, and x-axes, respectively.
X-Z-X 7 The first, second, and third rotations are about the x-, z-, and x-axes, respectively.
Y-X-Y 8 The first, second, and third rotations are about the y-, x-, and y-axes, respectively.
Y-Z-Y 9 The first, second, and third rotations are about the y-, z-, and y-axes, respectively.
Z-X-Z 10 The first, second, and third rotations are about the z-, x-, and z-axes, respectively.
Z-Y-Z 11 The first, second, and third rotations are about the z-, y-, and z-axes, respectively.

Default: Z-X-Z ## rotation type

Type of rotation to perform.

Name Value Description
Passive and Intrinsic 0 The rotation occurs about the axes of a rotating coordinate system, which is initially aligned with the fixed one, and modifies its orientation after each elemental rotation. The coordinate system rotates, while the coordinate is fixed.
Passive and Extrinsic 1 The rotation occurs about the axes of a fixed coordinate system. The coordinate system rotates, while the coordinate is fixed.
Active 2 The rotation occurs about the axes of the same coordinate system. The coordinate system is fixed, while the coordinate rotates.

Default: Passive and Intrinsic ## error in

Error conditions that occur before this node runs.

The node responds to this input according to standard error behavior.

Standard Error Behavior

Many nodes provide an error in input and an error out output so that the node can respond to and communicate errors that occur while code is running. The value of error in specifies whether an error occurred before the node runs. Most nodes respond to values of error in in a standard, predictable way.

error in does not contain an error error in contains an error  If no error occurred before the node runs, the node begins execution normally.

If no error occurs while the node runs, it returns no error. If an error does occur while the node runs, it returns that error information as error out.

If an error occurred before the node runs, the node does not execute. Instead, it returns the error in value as error out.

Default: No error ## Euler angles ### phi ### theta ### psi ## error out

Error information.

The node produces this output according to standard error behavior.

Standard Error Behavior

Many nodes provide an error in input and an error out output so that the node can respond to and communicate errors that occur while code is running. The value of error in specifies whether an error occurred before the node runs. Most nodes respond to values of error in in a standard, predictable way.

error in does not contain an error error in contains an error  If no error occurred before the node runs, the node begins execution normally.

If no error occurs while the node runs, it returns no error. If an error does occur while the node runs, it returns that error information as error out.

If an error occurred before the node runs, the node does not execute. Instead, it returns the error in value as error out.

## Algorithm for Converting Direction Cosines into Euler Angles

Direction cosines and Euler angles are two different ways of expressing a rotation. The following equations describe how this node converts direction cosines into Euler angles when rotation order is the default Z-X-Z and rotation type is the default Passive and Intrinsic:

$\left\{\begin{array}{c}\theta =\mathrm{arccos}\left({R}_{33}\right)\\ \varphi =\mathrm{atan2}\left({R}_{31},\text{\hspace{0.17em}}{-R}_{32}\text{\hspace{0.17em}}\right)\\ \psi =\mathrm{atan2}\left({R}_{13},\text{\hspace{0.17em}}{R}_{23}\text{\hspace{0.17em}}\right)\end{array}$

where

• θ, ϕ, and ψ are the output Euler angles
• Rij is the element at the ith row and jth column of the input direction cosines matrix

Where This Node Can Run:

Desktop OS: Windows

FPGA: Not supported

Web Server: Not supported in VIs that run in a web application