{ } Raw JSON

bundles / scipy 1.18.0 / scipy / spatial / transform / _rigid_transform / RigidTransform / identity

staticmethod

scipy.spatial.transform._rigid_transform:RigidTransform.identity

source: /scipy/spatial/transform/_rigid_transform.py:904

Signature

staticmethoddef identity(num: int | None = None, *, shape: int | tuple[int, ...] | None = None) → RigidTransform

Summary

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, optional

Number of identity transforms to generate. If None (default), then a single transform is generated.

shape : int or tuple of ints, optional

Shape of the identity transforms. If specified, num must be None.

Returns

transform : `RigidTransform` instance

The identity 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()
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(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)
✓
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
len(tf)
✓
2

Aliases

  • scipy.spatial.transform.RigidTransform.identity