You are viewing an older version (1.17.1).Go to latest (1.18.0)
{ } Raw JSON

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

staticmethod

scipy.spatial.transform._rotation:Rotation.from_mrp

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

Signature

staticmethoddef from_mrp(mrp: ArrayLike) → Rotation

Summary

Initialize from Modified Rodrigues Parameters (MRPs).

Extended Summary

MRPs are a 3 dimensional vector co-directional to the axis of rotation and whose magnitude is equal to tan(theta / 4), where theta is the angle of rotation (in radians) [1].

MRPs have a singularity at 360 degrees which can be avoided by ensuring the angle of rotation does not exceed 180 degrees, i.e. switching the direction of the rotation when it is past 180 degrees.

Parameters

mrp : array_like, shape (..., 3)

A single vector or an ND array of vectors, where the last dimension contains the rotation parameters.

Returns

rotation : `Rotation` instance

Object containing the rotations represented by input MRPs.

Notes

Array API Standard Support

from_mrp 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
✓
Initialize a single rotation:
r = R.from_mrp([0, 0, 1])
✓
r.as_euler('xyz', degrees=True)
✗
r.as_euler('xyz').shape
✓
Initialize multiple rotations in one object:
r = R.from_mrp([
[0, 0, 1],
[1, 0, 0]])
✓
r.as_euler('xyz', degrees=True)
✗
r.as_euler('xyz').shape
✓
It is also possible to have a stack of a single rotation:
r = R.from_mrp([[0, 0, np.pi/2]])
r.as_euler('xyz').shape
✓

Aliases

  • scipy.spatial.transform.Rotation.from_mrp