{ } Raw JSON

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

function

scipy.spatial.transform._rotation:Rotation.approx_equal

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

Signature

def   approx_equal ( self other : Rotation atol : float | None = None degrees : bool = False )  →  Array

Summary

Determine if another rotation is approximately equal to this one.

Extended Summary

Equality is measured by calculating the smallest angle between the rotations, and checking to see if it is smaller than atol.

Parameters

other : `Rotation` instance

Object containing the rotations to measure against this one.

atol : float, optional

The absolute angular tolerance, below which the rotations are considered equal. If not given, then set to 1e-8 radians by default.

degrees : bool, optional

If True and atol is given, then atol is measured in degrees. If False (default), then atol is measured in radians.

Returns

approx_equal : ndarray or bool

Whether the rotations are approximately equal, bool if object contains a single rotation and ndarray if object contains multiple rotations.

Notes

Array API Standard Support

approx_equal 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
p = R.from_quat([0, 0, 0, 1])
q = R.from_quat(np.eye(4))
p.approx_equal(q)
Approximate equality for a single rotation:
p.approx_equal(q[0])

Aliases

  • scipy.spatial.transform.Rotation.approx_equal