pyvista.Transform.as_rotation

pyvista.Transform.as_rotation#

Transform.as_rotation(
representation: Literal['quat', 'matrix', 'rotvec', 'mrp', 'euler', 'davenport'] | None = None,
*args,
**kwargs,
) Rotation | NumpyArray[float][ソース]#

Return the rotation component as a SciPy Rotation or any of its representations.

The current matrix is first decomposed to extract the rotation component and then returned with the specified representation.

注釈

This method depends on the scipy package which must be installed to use it.

パラメータ:
representationstr, optional

Representation of the rotation.

  • 'quat': Represent as a quaternion using as_quat(). Returns a length-4 vector.

  • 'matrix': Represent as a 3x3 matrix using as_matrix().

  • 'rotvec': Represent as a rotation vector using as_rotvec().

  • 'mrp': Represent as a Modified Rodrigues Parameters (MRPs) vector using as_mrp().

  • 'euler': Represent as Euler angles using as_euler().

  • 'davenport': Represent as Davenport angles using as_davenport().

If no representation is given, then an instance of scipy.spatial.transform.Rotation is returned by default.

*args

Arguments passed to the Rotation method for the specified representation.

**kwargs

Keyword arguments passed to the Rotation method for the specified representation.

戻り値:
scipy.spatial.transform.Rotation | np.ndarray

Rotation object or array depending on the representation.

参考

decompose

Alternative method for obtaining the rotation component (and others).

rotate, rotate_x, rotate_y, rotate_z, rotate_vector

Compose a rotation matrix.

Create a rotation matrix and initialize a Transform from it.

>>> import numpy as np
>>> import pyvista as pv
>>> matrix = [[0, -1, 0], [1, 0, 0], [0, 0, 1]]
>>> transform = pv.Transform(matrix)

Represent the rotation as scipy.spatial.transform.Rotation instance.

>>> rot = transform.as_rotation()
>>> rot
<scipy.spatial.transform._rotation.Rotation ...>

Represent the rotation as a quaternion.

>>> rot = transform.as_rotation('quat')
>>> rot
array([0.        , 0.        , 0.70710678, 0.70710678])

Represent the rotation as a rotation vector. The vector has a direction (0, 0, 1) and magnitude of pi/2.

>>> rot = transform.as_rotation('rotvec')
>>> rot
array([0.        , 0.        , 1.57079633])

Represent the rotation as a Modified Rodrigues Parameters vector.

>>> rot = transform.as_rotation('mrp')
>>> rot
array([0.        , 0.        , 0.41421356])

Represent the rotation as x-y-z Euler angles in degrees.

>>> rot = transform.as_rotation('euler', 'xyz', degrees=True)
>>> rot
array([ 0.,  0., 90.])

Represent the rotation as extrinsic x-y-z Davenport angles in degrees.

>>> rot = transform.as_rotation(
...     'davenport', np.eye(3), 'extrinsic', degrees=True
... )
>>> rot
array([-1.27222187e-14,  0.00000000e+00,  9.00000000e+01])