5.3.9. nvector.rotation.zyx2R

zyx2R(z, y, x)[source]

Returns rotation matrix from 3 angles about new axes in the zyx-order.

Parameters
z, y, x: real scalars or arrays of lenths n

Angles [rad] of rotation about new axes.

Returns
R_AB: 3 x 3 x n array

rotation matrix [no unit] (direction cosine matrix) such that the relation between a vector v decomposed in A and B is given by: v_A = mdot(R_AB, v_B)

See also

R2zyx, xyz2R, R2xyz

Notes

The rotation matrix R_AB is created based on 3 angles z,y,x about new axes (intrinsic) in the order z-y-x. The angles are called Euler angles or Tait-Bryan angles and are defined by the following procedure of successive rotations: Given two arbitrary coordinate frames A and B. Consider a temporary frame T that initially coincides with A. In order to make T align with B, we first rotate T an angle z about its z-axis (common axis for both A and T). Secondly, T is rotated an angle y about the NEW y-axis of T. Finally, T is rotated an angle x about its NEWEST x-axis. The final orientation of T now coincides with the orientation of B.

The signs of the angles are given by the directions of the axes and the right hand rule.

Note that if A is a north-east-down frame and B is a body frame, we have that z=yaw, y=pitch and x=roll.

See also: https://en.wikipedia.org/wiki/Aircraft_principal_axes https://en.wikipedia.org/wiki/Euler_angles https://en.wikipedia.org/wiki/Axes_conventions

Examples

Suppose the yaw angle between coordinate system A and B is 45 degrees. Convert position p1_b = (1, 0, 0) in B to a point in A. Convert position p2_a =(0, 1, 0) in A to a point in B.

Solution:
>>> import numpy as np
>>> import nvector as nv
>>> x, y, z = nv.rad(0, 0, 45)
>>> R_AB = nv.zyx2R(z, y, x)
>>> p1_b = np.atleast_2d((1, 0, 0)).T
>>> p1_a = nv.mdot(R_AB, p1_b)
>>> np.allclose(p1_a, [[0.7071067811865476], [0.7071067811865476], [0.0]])
True
>>> p2_a = np.atleast_2d((0, 1, 0)).T
>>> p2_b = nv.mdot(R_AB.T, p2_a)
>>> np.allclose(p2_b, [[0.7071067811865476], [0.7071067811865476], [0.0]])
True