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

# from_components

static RigidTransform.from_components(translation, rotation)

  Initialize a rigid transform from translation and rotation components.

  When creating a rigid transform from a translation and rotation, the translation is applied after the rotation, such that `tf = Tf.from_components(translation, rotation)` is equivalent to `tf = Tf.from_translation(translation) * Tf.from_rotation(rotation)`.

  When applying a transform to a vector `v`, the result is the same as if the transform was applied to the vector in the following way: `tf.apply(v) == translation + rotation.apply(v)`

  Parameters:
    translation array_like, shape (…, 3)

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

    rotation `Rotation` instance

      Rotation objects. The shape must be broadcastable with the translation shape.

  Returns:
    transform `RigidTransform` instance

      Rigid transform objects. The shape is determined by broadcasting the translation and rotation shapes together.

  Notes

  Array API Standard Support

  `from_components` 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
      >>> from scipy.spatial.transform import Rotation as R
      >>> import numpy as np

  Creating from a single rotation and translation:

      >>> t = np.array([2, 3, 4])
      >>> r = R.from_euler("ZYX", [90, 30, 0], degrees=True)
      >>> r.as_matrix()
      array([[ 0.       , -1.,  0.        ],
             [ 0.8660254,  0.,  0.5       ],
             [-0.5      ,  0.,  0.8660254 ]])
      >>> tf = Tf.from_components(t, r)
      >>> tf.rotation.as_matrix()
      array([[ 0.       , -1.,  0.        ],
             [ 0.8660254,  0.,  0.5       ],
             [-0.5      ,  0.,  0.8660254 ]])
      >>> tf.translation
      array([2., 3., 4.])
      >>> tf.single
      True

  When applying a transform to a vector `v`, the result is the same as if the transform was applied to the vector in the following way: `tf.apply(v) == translation + rotation.apply(v)`

      >>> r.apply([1, 0, 0])
      array([0.       , 0.8660254, -0.5     ])
      >>> t + r.apply([1, 0, 0])
      array([2.       , 3.8660254,  3.5     ])
      >>> tf.apply([1, 0, 0])
      array([2.       , 3.8660254,  3.5     ])