scipy.spatial.transform.RigidTransform.
inv#
- RigidTransform.inv(self)#
反转此变换。
一个变换与其逆变换的组合会产生一个单位变换。
刚性变换是旋转和平移的组合,其中先应用旋转,然后应用平移。因此,逆变换等效于逆平移后接逆旋转。
- 返回值:
RigidTransform
实例此变换的逆。
示例
>>> from scipy.spatial.transform import RigidTransform as Tf >>> from scipy.spatial.transform import Rotation as R >>> import numpy as np
与其逆变换组合的变换会产生一个单位变换
>>> rng = np.random.default_rng(seed=123) >>> t = rng.random(3) >>> r = R.random(rng=rng) >>> tf = Tf.from_components(t, r) >>> tf.as_matrix() array([[-0.45431291, 0.67276178, -0.58394466, 0.68235186], [-0.23272031, 0.54310598, 0.80676958, 0.05382102], [ 0.85990758, 0.50242162, -0.09017473, 0.22035987], [ 0. , 0. , 0. , 1. ]])
>>> (tf.inv() * tf).as_matrix() array([[[1., 0., 0., 0.], [0., 1., 0., 0.], [0., 0., 1., 0.], [0., 0., 0., 1.]]])
逆刚性变换与逆平移后接逆旋转相同
>>> t, r = tf.as_components() >>> r_inv = r.inv() # inverse rotation >>> t_inv = -t # inverse translation >>> tf_r_inv = Tf.from_rotation(r_inv) >>> tf_t_inv = Tf.from_translation(t_inv) >>> np.allclose((tf_r_inv * tf_t_inv).as_matrix(), ... tf.inv().as_matrix(), ... atol=1e-12) True >>> (tf_r_inv * tf_t_inv * tf).as_matrix() array([[[1., 0., 0., 0.], [0., 1., 0., 0.], [0., 0., 1., 0.], [0., 0., 0., 1.]]])