Skip to main content
`Ctrl`+`K`
scipy.spatial.transform.RigidTransform.

# from_translation

static RigidTransform.from_translation(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:
    translation array_like, shape (…, 3)

      Translation vectors. Each translation[…, :] represents a 3D translation vector.

  Returns:
    transform `RigidTransform` instance

      Object containing the rigid transform represented by the input translation.

  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 an N-dimensional array 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