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

# from_rotvec

static Rotation.from_rotvec(rotvec, degrees=False)

  Initialize from rotation vectors.

  A rotation vector is a 3 dimensional vector which is co-directional to the axis of rotation and whose norm gives the angle of rotation [1].

  Parameters:
    rotvec array_like, shape (…, 3)

      A single vector or an ND array of vectors, where the last dimension contains the rotation vectors.

    degrees bool, optional

      If True, then the given magnitudes are assumed to be in degrees. Default is False.

      Added in version 1.7.0.

  Returns:
    rotation `Rotation` instance

      Object containing the rotations represented by input rotation vectors.

  References

  [1]

  https://en.wikipedia.org/wiki/Axis%E2%80%93angle_representation#Rotation_vector

  Examples

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

  Initialize a single rotation:

      >>> r = R.from_rotvec(np.pi/2 * np.array([0, 0, 1]))
      >>> r.as_rotvec()
      array([0.        , 0.        , 1.57079633])
      >>> r.as_rotvec().shape
      (3,)

  Initialize a rotation in degrees, and view it in degrees:

      >>> r = R.from_rotvec(45 * np.array([0, 1, 0]), degrees=True)
      >>> r.as_rotvec(degrees=True)
      array([ 0., 45.,  0.])

  Initialize multiple rotations in one object:

      >>> r = R.from_rotvec([
      ... [0, 0, np.pi/2],
      ... [np.pi/2, 0, 0]])
      >>> r.as_rotvec()
      array([[0.        , 0.        , 1.57079633],
             [1.57079633, 0.        , 0.        ]])
      >>> r.as_rotvec().shape
      (2, 3)

  It is also possible to have a stack of a single rotation:

      >>> r = R.from_rotvec([[0, 0, np.pi/2]])
      >>> r.as_rotvec().shape
      (1, 3)