scipy.spatial.transform.RigidTransform.
from_rotation#
- classmethod RigidTransform.from_rotation(cls, rotation)#
从旋转初始化,没有平移。
当将此变换应用于向量
v
时,结果与将旋转应用于向量相同。Tf.from_rotation(r).apply(v) == r.apply(v)
- 参数:
- rotation
Rotation
实例 单个旋转或一堆旋转。
- rotation
- 返回:
- transform
RigidTransform
实例
- transform
示例
>>> from scipy.spatial.transform import RigidTransform as Tf >>> from scipy.spatial.transform import Rotation as R >>> import numpy as np
从单个旋转创建变换
>>> 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
变换矩阵的左上 3x3 子矩阵是旋转矩阵
>>> np.allclose(tf.as_matrix()[:3, :3], r.as_matrix(), atol=1e-12) True
从一堆旋转创建多个变换
>>> 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