{ } Raw JSON

bundles / scipy 1.17.1 / scipy / spatial / transform / _rotation / Rotation / magnitude

function

scipy.spatial.transform._rotation:Rotation.magnitude

source: /scipy/spatial/transform/_rotation.py :1907

Signature

def   magnitude ( self )  →  Array

Summary

Get the magnitude(s) of the rotation(s).

Returns

magnitude : ndarray or float

Angle(s) in radians, float if object contains a single rotation and ndarray if object contains ND rotations. The magnitude will always be in the range [0, pi].

Notes

Array API Standard Support

magnitude 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-arrayapi for more information.

Examples

from scipy.spatial.transform import Rotation as R
import numpy as np
r = R.from_quat(np.eye(4))
r.as_quat()
r.magnitude()
Magnitude of a single rotation:
r[0].magnitude()

Aliases

  • scipy.spatial.transform.Rotation.magnitude