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

# from_exp_coords

static RigidTransform.from_exp_coords(exp_coords)

  Initialize from exponential coordinates of transform.

  This implements the exponential map that converts 6-dimensional real vectors to SE(3).

  An exponential coordinate vector consists of 6 elements `[rx, ry, rz, vx, vy, vz]`. The first 3 encode rotation (and form a rotation vector used in `Rotation.from_rotvec`) and the last 3 encode translation (and form a translation vector for pure translations). The exponential mapping can be expressed as matrix exponential `T = exp(tau)`, where `T` is a 4x4 matrix representing a rigid transform and `tau` is a 4x4 matrix formed from the elements of an exponential coordinate vector:

      tau = [  0 -rz  ry vx]
            [ rz   0 -rx vy]
            [-ry  rx   0 vz]
            [  0   0   0  1]

  Parameters:
    exp_coords array_like, shape (…, 6)

      Exponential coordinate vectors. Each exp_coords[…, :] represents a 6D exponential coordinate vector with the expected order of components `[rx, ry, rz, vx, vy, vz]`. The first 3 components encode rotation and the last 3 encode translation.

  Returns:
    transform `RigidTransform` instance

      Rigid transform objects with the same leading dimensions as the input.

  Notes

  Array API Standard Support

  `from_exp_coords` has experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variable `SCIPY_ARRAY_API=1` and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following combinations of backend and device (or other capability) are supported.

  Library | CPU | GPU
  --- | --- | ---
  NumPy | ✅ | n/a
  CuPy | n/a | ✅
  PyTorch | ✅ | ✅
  JAX | ✅ | ✅
  Dask | ⛔ | n/a

  > See Support for the array API standard for more information.

  Examples

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

  Creating from a single 6d vector of exponential coordinates:

      >>> tf = Tf.from_exp_coords([
      ...     -2.01041204, -0.52983629, 0.65773501,
      ...     0.10386614, 0.05855009, 0.54959179])
      >>> tf.as_matrix()
      array([[0.76406621, 0.10504613, -0.63652819, -0.10209961],
             [0.59956454, -0.47987325, 0.64050295, 0.40158789],
             [-0.2381705, -0.87102639, -0.42963687, 0.19637636],
             [0., 0., 0., 1.]])
      >>> tf.single
      True

  A vector of zeros represents the identity transform:

      >>> tf = Tf.from_exp_coords(np.zeros(6))
      >>> tf.as_matrix()
      array([[1., 0., 0., 0.],
             [0., 1., 0., 0.],
             [0., 0., 1., 0.],
             [0., 0., 0., 1.]])

  The last three numbers encode translation. If the first three numbers are zero, the last three components can be interpreted as the translation:

      >>> tf_trans = Tf.from_exp_coords([0, 0, 0, 4.3, -2, 3.4])
      >>> tf_trans.translation
      array([4.3, -2., 3.4])

  The first three numbers encode rotation as a rotation vector:

      >>> tf_rot = Tf.from_exp_coords([0.5, 0.3, 0.1, 0, 0, 0])
      >>> tf_rot.rotation.as_rotvec()
      array([0.5, 0.3, 0.1])

  Combining translation and rotation preserves the rotation vector, but changes the last three components as they encode translation and rotation:

      >>> (tf_trans * tf_rot).as_exp_coords()
      array([0.5, 0.3, 0.1, 3.64305882, -1.25879559, 4.46109265])