scipy.spatial.transform.RigidTransform.

as_components#

RigidTransform.as_components(self)#

返回变换的平移和旋转分量,其中先应用旋转,然后进行平移。

4x4 刚性变换矩阵的形式为

[R | t] [0 | 1]

其中 R 是 3x3 正交旋转矩阵,t 是 3x1 平移向量 [tx, ty, tz]。此函数返回对应于此旋转矩阵 r = Rotation.from_matrix(R) 的旋转和平移向量 t

取一个变换 tf 和一个向量 v。当将变换应用于向量时,结果与以下方式应用于向量的结果相同: tf.apply(v) == translation + rotation.apply(v)

返回:
translationnumpy.ndarray,形状 (N, 3) 或 (3,)

变换的平移。

rotationRotation 实例

变换的旋转。

示例

>>> from scipy.spatial.transform import RigidTransform as Tf
>>> from scipy.spatial.transform import Rotation as R
>>> import numpy as np

从变换中恢复旋转和平移

>>> 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.]])

应用于向量的变换等效于应用于向量的旋转,然后进行平移

>>> 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.])