scipy.spatial.transform.RigidTransform.

from_translation#

classmethod RigidTransform.from_translation(cls, translation)#

Initialize from a translation numpy array, without a rotation.

When applying this transform to a vector v, the result is the same as if the translation and vector were added together. If t is the displacement vector of the translation, then:

Tf.from_translation(t).apply(v) == t + v

Parameters:
translationarray_like, shape (N, 3) or (3,)

A single translation vector or a stack of translation vectors.

Returns:
transformRigidTransform instance

Examples

>>> from scipy.spatial.transform import RigidTransform as Tf
>>> import numpy as np

Creating a transform from a single translation vector:

>>> t = np.array([2, 3, 4])
>>> t + np.array([1, 0, 0])
array([3, 3, 4])
>>> tf = Tf.from_translation(t)
>>> tf.apply([1, 0, 0])
array([3., 3., 4.])
>>> tf.single
True

The top 3x1 points in the rightmost column of the transformation matrix is the translation vector:

>>> tf.as_matrix()
array([[1., 0., 0., 2.],
       [0., 1., 0., 3.],
       [0., 0., 1., 4.],
       [0., 0., 0., 1.]])
>>> np.allclose(tf.as_matrix()[:3, 3], t)
True

Creating multiple transforms from a stack of translation vectors:

>>> t = np.array([[2, 3, 4], [1, 0, 0]])
>>> t + np.array([1, 0, 0])
array([[3, 3, 4],
       [2, 0, 0]])
>>> tf = Tf.from_translation(t)
>>> tf.apply([1, 0, 0])
array([[3., 3., 4.],
       [2., 0., 0.]])
>>> np.allclose(tf.as_matrix()[:, :3, 3], t)
True
>>> tf.single
False
>>> len(tf)
2