{ } Raw JSON

bundles / scipy latest / scipy / spatial / transform / _rotation / Rotation / as_matrix

function

scipy.spatial.transform._rotation:Rotation.as_matrix

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

Signature

def   as_matrix ( self )  →  Array

Summary

Represent as rotation matrix.

Extended Summary

3D rotations can be represented using rotation matrices, which are 3 x 3 real orthogonal matrices with determinant equal to +1 [1].

Returns

matrix : ndarray, shape (..., 3)

Shape depends on shape of inputs used for initialization.

Notes

This function was called as_dcm before.

Array API Standard Support

as_matrix 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
Represent a single rotation:
r = R.from_rotvec([0, 0, np.pi/2])
r.as_matrix()
r.as_matrix().shape
Represent a stack with a single rotation:
r = R.from_quat([[1, 1, 0, 0]])
r.as_matrix()
r.as_matrix().shape
Represent multiple rotations:
r = R.from_rotvec([[np.pi/2, 0, 0], [0, 0, np.pi/2]])
r.as_matrix()
r.as_matrix().shape

Aliases

  • scipy.spatial.transform.Rotation.as_matrix