mean#
- Rotation.mean(weights=None)[source]#
Get the mean of the rotations.
The mean used is the chordal L2 mean (also called the projected or induced arithmetic mean) [1]. If
A
is a set of rotation matrices, then the meanM
is the rotation matrix that minimizes the following loss function:\[L(M) = \sum_{i = 1}^{n} w_i \lVert \mathbf{A}_i - \mathbf{M} \rVert^2 ,\]where \(w_i\)’s are the weights corresponding to each matrix.
- Parameters:
- weightsarray_like shape (N,), optional
Weights describing the relative importance of the rotations. If None (default), then all values in weights are assumed to be equal.
- Returns:
- mean
Rotation
instance Object containing the mean of the rotations in the current instance.
- mean
Notes
Array API Standard Support
mean
has experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variableSCIPY_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 Support for the array API standard for more information.
References
[1]Hartley, Richard, et al., “Rotation Averaging”, International Journal of Computer Vision 103, 2013, pp. 267-305.
Examples
>>> from scipy.spatial.transform import Rotation as R >>> r = R.from_euler('zyx', [[0, 0, 0], ... [1, 0, 0], ... [0, 1, 0], ... [0, 0, 1]], degrees=True) >>> r.mean().as_euler('zyx', degrees=True) array([0.24945696, 0.25054542, 0.24945696])