bundles / scipy 1.17.1 / scipy / spatial / transform / _rotation / Rotation / as_euler
function
scipy.spatial.transform._rotation:Rotation.as_euler
Signature
def as_euler ( self , seq : str , degrees : bool = False , * , suppress_warnings : bool = False ) → Array Summary
Represent as Euler angles.
Extended Summary
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 (unless the suppress_warnings option is used), and the third angle is set to zero. Note however that the returned angles still represent the correct rotation.
Parameters
seq: string, length 33 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.
degrees: boolean, optionalReturned angles are in degrees if this flag is True, else they are in radians. Default is False.
suppress_warnings: boolean, optionalDisable warnings about gimbal lock. Default is False.
Returns
angles: ndarray, shape (..., 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)
Notes
Array API Standard Support
as_euler has experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variable SCIPY_ARRAY_API=1 and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following combinations of backend and device (or other capability) are supported.
==================== ==================== ==================== Library CPU GPU ==================== ==================== ==================== NumPy ✅ n/a CuPy n/a ✅ PyTorch ✅ ✅ JAX ✅ ✅ Dask ⛔ n/a ==================== ==================== ====================
See
dev-arrayapifor more information.
Examples
from scipy.spatial.transform import Rotation as R import numpy as np✓
r = R.from_rotvec([0, 0, np.pi/2]) r.as_euler('zxy', degrees=True) r.as_euler('zxy', degrees=True).shape✓
r = R.from_rotvec([[0, 0, np.pi/2]]) r.as_euler('zxy', degrees=True) r.as_euler('zxy', degrees=True).shape✓
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) r.as_euler('zxy', degrees=True).shape✓
Aliases
-
scipy.spatial.transform.Rotation.as_euler