scipy.spatial.transform.RigidTransform.
from_rotation#
- classmethod RigidTransform.from_rotation(cls, rotation)#
- Initialize from a rotation, without a translation. - 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:
- rotationRotationinstance
- A single rotation or a stack of rotations. 
 
- rotation
- Returns:
- transformRigidTransforminstance
 
- transform
 - 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.8660254, -0.5 ]) >>> tf = Tf.from_rotation(r) >>> tf.apply([1, 0, 0]) array([0. , 0.8660254, -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 stack of rotations: - >>> r = R.from_euler("ZYX", [[90, 30, 0], [45, 30, 60]], degrees=True) >>> r.apply([1, 0, 0]) array([[0. , 0.8660254 , -0.5 ], [0.61237244, 0.61237244, -0.5 ]]) >>> tf = Tf.from_rotation(r) >>> tf.apply([1, 0, 0]) array([[0. , 0.8660254 , -0.5 ], [0.61237244, 0.61237244, -0.5 ]]) >>> tf.single False >>> len(tf) 2