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

# from_rotation

static RigidTransform.from_rotation(rotation)

  Initialize from a rotation, without a translation.

  When applying this transform to a vector `v`, the result is the same as if the rotation was applied to the vector. `Tf.from_rotation(r).apply(v) == r.apply(v)`

  Parameters:
    rotation `Rotation` instance

      A single rotation or a rotation with N leading dimensions.

  Returns:
    transform `RigidTransform` instance

      Object containing the rigid transform represented by the input rotation.

  Examples

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

  Creating a transform from a single rotation:

      >>> r = R.from_euler("ZYX", [90, 30, 0], degrees=True)
      >>> r.apply([1, 0, 0])
      array([0.       , 0.8660254, -0.5     ])
      >>> tf = Tf.from_rotation(r)
      >>> tf.apply([1, 0, 0])
      array([0.       , 0.8660254, -0.5     ])
      >>> tf.single
      True

  The upper 3x3 submatrix of the transformation matrix is the rotation matrix:

      >>> np.allclose(tf.as_matrix()[:3, :3], r.as_matrix(), atol=1e-12)
      True

  Creating multiple transforms from a rotation with N leading dimensions:

      >>> r = R.from_euler("ZYX", [[90, 30, 0], [45, 30, 60]], degrees=True)
      >>> r.apply([1, 0, 0])
      array([[0.        , 0.8660254 , -0.5       ],
             [0.61237244, 0.61237244, -0.5       ]])
      >>> tf = Tf.from_rotation(r)
      >>> tf.apply([1, 0, 0])
      array([[0.        , 0.8660254 , -0.5       ],
             [0.61237244, 0.61237244, -0.5       ]])
      >>> tf.single
      False
      >>> len(tf)
      2