scipy.spatial.transform.RigidTransform.
identity#
- classmethod RigidTransform.identity(cls, num=None)#
Initialize an identity transform.
Composition with the identity transform has no effect, and applying the identity transform to a vector has no effect.
- Parameters:
- numint, optional
Number of identity transforms to generate. If None (default), then a single transform is generated.
- Returns:
- transform
RigidTransform
instance The identity transform.
- transform
Examples
>>> from scipy.spatial.transform import RigidTransform as Tf >>> from scipy.spatial.transform import Rotation as R >>> import numpy as np
Creating a single identity transform:
>>> tf = Tf.identity() >>> tf.as_matrix() array([[1., 0., 0., 0.], [0., 1., 0., 0.], [0., 0., 1., 0.], [0., 0., 0., 1.]]) >>> tf.single True
The identity transform can be applied to a vector without effect:
>>> tf.apply([1, 2, 3]) array([1., 2., 3.])
The identity transform when composed with another transform has no effect:
>>> rng = np.random.default_rng() >>> t = rng.random(3) >>> r = R.random(rng=rng) >>> tf = Tf.from_components(t, r) >>> np.allclose((Tf.identity() * tf).as_matrix(), ... tf.as_matrix(), atol=1e-12) True
Multiple identity transforms can be generated at once:
>>> tf = Tf.identity(2) >>> tf.as_matrix() array([[[1., 0., 0., 0.], [0., 1., 0., 0.], [0., 0., 1., 0.], [0., 0., 0., 1.]], [[1., 0., 0., 0.], [0., 1., 0., 0.], [0., 0., 1., 0.], [0., 0., 0., 1.]]]) >>> tf.single False >>> len(tf) 2