{ } Raw JSON

bundles / scipy 1.18.0 / scipy / spatial / transform / _rigid_transform / RigidTransform / from_rotation

staticmethod

scipy.spatial.transform._rigid_transform:RigidTransform.from_rotation

source: /scipy/spatial/transform/_rigid_transform.py:550

Signature

staticmethoddef from_rotation(rotation: Rotation) → RigidTransform

Summary

Initialize from a rotation, without a translation.

Extended Summary

When applying this transform to a vector v, the result is the same as if the rotation was applied to the vector. Tf.from_rotation(r).apply(v) == r.apply(v)

Parameters

rotation : `Rotation` instance

A single rotation or a rotation with N leading dimensions.

Returns

transform : `RigidTransform` instance

Object containing the rigid transform represented by the input rotation.

Examples

from scipy.spatial.transform import RigidTransform as Tf
from scipy.spatial.transform import Rotation as R
import numpy as np
✓
Creating a transform from a single rotation:
r = R.from_euler("ZYX", [90, 30, 0], degrees=True)
✓
r.apply([1, 0, 0])
✗
array([ 0.     ,  0.86603, -0.5    ])
tf = Tf.from_rotation(r)
✓
tf.apply([1, 0, 0])
✗
array([ 0.     ,  0.86603, -0.5    ])
tf.single
✓
True
The upper 3x3 submatrix of the transformation matrix is the rotation matrix:
np.allclose(tf.as_matrix()[:3, :3], r.as_matrix(), atol=1e-12)
✓
True
Creating multiple transforms from a rotation with N leading dimensions:
r = R.from_euler("ZYX", [[90, 30, 0], [45, 30, 60]], degrees=True)
✓
r.apply([1, 0, 0])
✗
array([[ 0.     ,  0.86603, -0.5    ],
       [ 0.61237,  0.61237, -0.5    ]])
tf = Tf.from_rotation(r)
✓
tf.apply([1, 0, 0])
✗
array([[ 0.     ,  0.86603, -0.5    ],
       [ 0.61237,  0.61237, -0.5    ]])
tf.single
len(tf)
✓
2

Aliases

  • scipy.spatial.transform.RigidTransform.from_rotation