# scipy.spatial.transform.Rotation.as_euler¶

Rotation.as_euler()

Represent as Euler angles.

Any orientation can be expressed as a composition of 3 elementary rotations. Once the axis sequence has been chosen, Euler angles define the angle of rotation around each respective axis [1].

The algorithm from [2] has been used to calculate Euler angles for the rotation about a given sequence of axes.

Euler angles suffer from the problem of gimbal lock [3], where the representation loses a degree of freedom and it is not possible to determine the first and third angles uniquely. In this case, a warning is raised, and the third angle is set to zero. Note however that the returned angles still represent the correct rotation.

Parameters
seqstring, length 3

3 characters belonging to the set {‘X’, ‘Y’, ‘Z’} for intrinsic rotations, or {‘x’, ‘y’, ‘z’} for extrinsic rotations [1]. Adjacent axes cannot be the same. Extrinsic and intrinsic rotations cannot be mixed in one function call.

degreesboolean, optional

Returned angles are in degrees if this flag is True, else they are in radians. Default is False.

Returns
anglesndarray, shape (3,) or (N, 3)

Shape depends on shape of inputs used to initialize object. The returned angles are in the range:

• First angle belongs to [-180, 180] degrees (both inclusive)

• Third angle belongs to [-180, 180] degrees (both inclusive)

• Second angle belongs to:

• [-90, 90] degrees if all axes are different (like xyz)

• [0, 180] degrees if first and third axes are the same (like zxz)

References

1(1,2)

https://en.wikipedia.org/wiki/Euler_angles#Definition_by_intrinsic_rotations

2

Malcolm D. Shuster, F. Landis Markley, “General formula for extraction the Euler angles”, Journal of guidance, control, and dynamics, vol. 29.1, pp. 215-221. 2006

3

https://en.wikipedia.org/wiki/Gimbal_lock#In_applied_mathematics

Examples

>>> from scipy.spatial.transform import Rotation as R


Represent a single rotation:

>>> r = R.from_rotvec([0, 0, np.pi/2])
>>> r.as_euler('zxy', degrees=True)
array([90.,  0.,  0.])
>>> r.as_euler('zxy', degrees=True).shape
(3,)


Represent a stack of single rotation:

>>> r = R.from_rotvec([[0, 0, np.pi/2]])
>>> r.as_euler('zxy', degrees=True)
array([[90.,  0.,  0.]])
>>> r.as_euler('zxy', degrees=True).shape
(1, 3)


Represent multiple rotations in a single object:

>>> r = R.from_rotvec([
... [0, 0, np.pi/2],
... [0, -np.pi/3, 0],
... [np.pi/4, 0, 0]])
>>> r.as_euler('zxy', degrees=True)
array([[ 90.,   0.,   0.],
[  0.,   0., -60.],
[  0.,  45.,   0.]])
>>> r.as_euler('zxy', degrees=True).shape
(3, 3)