bundles / scipy latest / scipy / spatial / transform / _rotation / Rotation / __mul__
function
scipy.spatial.transform._rotation:Rotation.__mul__
Signature
def __mul__ ( self , other : Rotation ) → Rotation | NotImplementedType Summary
Compose this rotation with the other.
Extended Summary
If p and q are two rotations, then the composition of 'q followed by p' is equivalent to p * q. In terms of rotation matrices, the composition can be expressed as p.as_matrix() @ q.as_matrix().
Parameters
other: `Rotation` instanceObject containing the rotations to be composed with this one. Note that rotation compositions are not commutative, so
p * qis generally different fromq * p.
Returns
composition: `Rotation` instanceThis function supports composition of multiple rotations at a time. Composition follows standard numpy broadcasting rules. The resulting Rotation object will have the shape
np.broadcast_shapes(p.shape, q.shape). In dimensions with size > 1, rotations are composed with matching indices. In dimensions with only one rotation, the single rotation is composed with each rotation in the other object.
Notes
Array API Standard Support
__mul__ 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✓
p = R.from_quat([0, 0, 1, 1]) q = R.from_quat([1, 0, 0, 1]) p.as_matrix() q.as_matrix() r = p * q r.as_matrix()✓
p = R.from_quat([[0, 0, 1, 1], [1, 0, 0, 1]]) q = R.from_rotvec([[np.pi/4, 0, 0], [-np.pi/4, 0, np.pi/4]])✓
p.as_quat() q.as_quat()✗
r = p * q
✓r.as_quat()
✗p = R.from_quat(np.tile(np.array([0, 0, 1, 1]), (5, 1, 1))) q = R.from_quat(np.tile(np.array([1, 0, 0, 1]), (1, 6, 1))) p.shape, q.shape r = p * q r.shape✓
Aliases
-
scipy.spatial.transform.Rotation.__mul__