scipy.spatial.transform.RigidTransform.
__getitem__#
- RigidTransform.__getitem__()#
Extract transform(s) at given index(es) from this object.
Creates a new
RigidTransform
instance containing a subset of transforms stored in this object.- Parameters:
- indexerint or slice or array_like
Specifies which transform(s) to extract. A single indexer must be specified, i.e. as if indexing a 1 dimensional array or list.
- Returns:
- transform
RigidTransform
instance - Contains
a single transform, if indexer is a single index
a stack of transform(s), if indexer is a slice, or an index array.
- transform
- Raises:
- TypeError
If the transform is a single transform.
Examples
>>> from scipy.spatial.transform import RigidTransform as Tf >>> t = [[0, 0, 0], [1, 0, 0], [2, 0, 0]] # 3 translations >>> tf = Tf.from_translation(t)
A single index returns a single transform:
>>> tf[0].as_matrix() array([[1., 0., 0., 0.], [0., 1., 0., 0.], [0., 0., 1., 0.], [0., 0., 0., 1.]])
A slice returns a stack of transforms:
>>> tf[1:3].translation array([[1., 0., 0.], [2., 0., 0.]])
An index array returns a stack of transforms:
>>> tf[[0, 2]].translation array([[0., 0., 0.], [2., 0., 0.]])