bundles / scipy 1.18.0 / scipy / spatial / transform / _rigid_transform / RigidTransform / identity
staticmethod
scipy.spatial.transform._rigid_transform:RigidTransform.identity
Signature
staticmethod
def identity(num: int | None = None, *, shape: int | tuple[int, ...] | None = None) → RigidTransformSummary
Initialize an identity transform.
Extended Summary
Composition with the identity transform has no effect, and applying the identity transform to a vector has no effect.
Parameters
num: int, optionalNumber of identity transforms to generate. If None (default), then a single transform is generated.
shape: int or tuple of ints, optionalShape of the identity transforms. If specified,
nummust be None.
Returns
transform: `RigidTransform` instanceThe identity transform.
Examples
from scipy.spatial.transform import RigidTransform as Tf from scipy.spatial.transform import Rotation as R import numpy as np✓
tf = Tf.identity() tf.as_matrix() tf.single✓
TrueThe 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(123) 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)✓
TrueMultiple 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 len(tf)✓
2
Aliases
scipy.spatial.transform.RigidTransform.identity