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

# as_rotvec

Rotation.as_rotvec(degrees=False)

  Represent as 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:
    degrees boolean, optional

      Returned magnitudes are in degrees if this flag is True, else they are in radians. Default is False.

      Added in version 1.7.0.

  Returns:
    rotvec ndarray, shape (…, 3)

      Shape depends on shape of inputs used for initialization.

  Notes

  Array API Standard Support

  `as_rotvec` 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.

  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

  Represent a single rotation:

      >>> r = R.from_euler('z', 90, degrees=True)
      >>> r.as_rotvec()
      array([0.        , 0.        , 1.57079633])
      >>> r.as_rotvec().shape
      (3,)

  Represent a rotation in degrees:

      >>> r = R.from_euler('YX', (-90, -90), degrees=True)
      >>> s = r.as_rotvec(degrees=True)
      >>> s
      array([-69.2820323, -69.2820323, -69.2820323])
      >>> np.linalg.norm(s)
      120.00000000000001

  Represent a stack with a single rotation:

      >>> r = R.from_quat([[0, 0, 1, 1]])
      >>> r.as_rotvec()
      array([[0.        , 0.        , 1.57079633]])
      >>> r.as_rotvec().shape
      (1, 3)

  Represent multiple rotations in a single object:

      >>> r = R.from_quat([[0, 0, 1, 1], [1, 1, 0, 1]])
      >>> r.as_rotvec()
      array([[0.        , 0.        , 1.57079633],
             [1.35102172, 1.35102172, 0.        ]])
      >>> r.as_rotvec().shape
      (2, 3)