as_components#
- RigidTransform.as_components(self)#
Return the translation and rotation components of the transform, where the rotation is applied first, followed by the translation.
4x4 rigid transformation matrices are of the form:
[R | t] [0 | 1]
Where
R
is a 3x3 orthonormal rotation matrix andt
is a 3x1 translation vector[tx, ty, tz]
. This function returns the rotation corresponding to this rotation matrixr = Rotation.from_matrix(R)
and the translation vectort
.Take a transform
tf
and a vectorv
. When applying the transform to the vector, 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)
- Returns:
- translationnumpy.ndarray, shape (N, 3) or (3,)
The translation of the transform.
- rotation
Rotation
instance The rotation of the transform.
Examples
>>> from scipy.spatial.transform import RigidTransform as Tf >>> from scipy.spatial.transform import Rotation as R >>> import numpy as np
Recover the rotation and translation from a transform:
>>> t = np.array([2, 3, 4]) >>> r = R.from_matrix([[0, 0, 1], ... [1, 0, 0], ... [0, 1, 0]]) >>> tf = Tf.from_components(t, r) >>> tf_t, tf_r = tf.as_components() >>> tf_t array([2., 3., 4.]) >>> tf_r.as_matrix() array([[0., 0., 1.], [1., 0., 0.], [0., 1., 0.]])
The transform applied to a vector is equivalent to the rotation applied to the vector followed by the translation:
>>> r.apply([1, 0, 0]) array([0., 1., 0.]) >>> t + r.apply([1, 0, 0]) array([2., 4., 4.]) >>> tf.apply([1, 0, 0]) array([2., 4., 4.])