scipy.spatial.transform.Rotation.from_euler#

Rotation.from_euler(type cls, seq, angles, degrees=False)#

Initialize from Euler angles.

Rotations in 3-D can be represented by a sequence of 3 rotations around a sequence of axes. In theory, any three axes spanning the 3-D Euclidean space are enough. In practice, the axes of rotation are chosen to be the basis vectors.

The three rotations can either be in a global frame of reference (extrinsic) or in a body centred frame of reference (intrinsic), which is attached to, and moves with, the object under rotation [1].

Parameters:
seqstring

Specifies sequence of axes for rotations. Up to 3 characters belonging to the set {‘X’, ‘Y’, ‘Z’} for intrinsic rotations, or {‘x’, ‘y’, ‘z’} for extrinsic rotations. Extrinsic and intrinsic rotations cannot be mixed in one function call.

anglesfloat or array_like, shape (N,) or (N, [1 or 2 or 3])

Euler angles specified in radians (degrees is False) or degrees (degrees is True). For a single character seq, angles can be:

  • a single value

  • array_like with shape (N,), where each angle[i] corresponds to a single rotation

  • array_like with shape (N, 1), where each angle[i, 0] corresponds to a single rotation

For 2- and 3-character wide seq, angles can be:

  • array_like with shape (W,) where W is the width of seq, which corresponds to a single rotation with W axes

  • array_like with shape (N, W) where each angle[i] corresponds to a sequence of Euler angles describing a single rotation

degreesbool, optional

If True, then the given angles are assumed to be in degrees. Default is False.

Returns:
rotationRotation instance

Object containing the rotation represented by the sequence of rotations around given axes with given angles.

References

Examples

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

Initialize a single rotation along a single axis:

>>> r = R.from_euler('x', 90, degrees=True)
>>> r.as_quat().shape
(4,)

Initialize a single rotation with a given axis sequence:

>>> r = R.from_euler('zyx', [90, 45, 30], degrees=True)
>>> r.as_quat().shape
(4,)

Initialize a stack with a single rotation around a single axis:

>>> r = R.from_euler('x', [90], degrees=True)
>>> r.as_quat().shape
(1, 4)

Initialize a stack with a single rotation with an axis sequence:

>>> r = R.from_euler('zyx', [[90, 45, 30]], degrees=True)
>>> r.as_quat().shape
(1, 4)

Initialize multiple elementary rotations in one object:

>>> r = R.from_euler('x', [90, 45, 30], degrees=True)
>>> r.as_quat().shape
(3, 4)

Initialize multiple rotations in one object:

>>> r = R.from_euler('zyx', [[90, 45, 30], [35, 45, 90]], degrees=True)
>>> r.as_quat().shape
(2, 4)