from_components#
- classmethod RigidTransform.from_components(cls, translation, rotation)#
- Initialize a rigid transform from translation and rotation components. - When creating a rigid transform from a translation and rotation, the translation is applied after the rotation, such that - tf = Tf.from_components(translation, rotation)is equivalent to- tf = Tf.from_translation(translation) * Tf.from_rotation(rotation).- When applying a transform to a vector - v, the result is the same as if the transform was applied to the vector in the following way:- tf.apply(v) == translation + rotation.apply(v)- Parameters:
- translationarray_like, shape (N, 3) or (3,)
- A single translation vector or a stack of translation vectors. 
- rotationRotationinstance
- A single rotation or a stack of rotations. 
 
- Returns:
- RigidTransform
- If rotation is single and translation is shape (3,), then a single transform is returned. Otherwise, a stack of transforms is returned. 
 
 - Examples - >>> from scipy.spatial.transform import RigidTransform as Tf >>> from scipy.spatial.transform import Rotation as R >>> import numpy as np - Creating from a single rotation and translation: - >>> t = np.array([2, 3, 4]) >>> r = R.from_euler("ZYX", [90, 30, 0], degrees=True) >>> r.as_matrix() array([[ 0. , -1., 0. ], [ 0.8660254, 0., 0.5 ], [-0.5 , 0., 0.8660254 ]]) >>> tf = Tf.from_components(t, r) >>> tf.rotation.as_matrix() array([[ 0. , -1., 0. ], [ 0.8660254, 0., 0.5 ], [-0.5 , 0., 0.8660254 ]]) >>> tf.translation array([2., 3., 4.]) >>> tf.single True - When applying a transform to a vector - v, the result is the same as if the transform was applied to the vector in the following way:- tf.apply(v) == translation + rotation.apply(v)- >>> r.apply([1, 0, 0]) array([0. , 0.8660254, -0.5 ]) >>> t + r.apply([1, 0, 0]) array([2. , 3.8660254, 3.5 ]) >>> tf.apply([1, 0, 0]) array([2. , 3.8660254, 3.5 ])