This is a pre-release version (2.0.0.dev0+git20260907.41eeb59).Go to latest (1.18.0)
{ } Raw JSON

bundles / scipy 2.0.0.dev0+git20260907.41eeb59 / scipy / spatial / transform / _rotation / Rotation / as_davenport

function

scipy.spatial.transform._rotation:Rotation.as_davenport

source: build-install/usr/lib/python3.14/site-packages/scipy/spatial/transform/_rotation.py:1322

Signature

def as_davenport(self, axes: ArrayLike, order: str, degrees: bool = False, *, suppress_warnings: bool = False) → Array

Summary

Represent as Davenport angles.

Extended Summary

Any orientation can be expressed as a composition of 3 elementary rotations.

For both Euler angles and Davenport angles, consecutive axes must be orthogonal (axis2 is orthogonal to both axis1 and axis3). For Euler angles, there is an additional relationship between axis1 or axis3, with two possibilities:

  • axis1 and axis3 are also orthogonal (asymmetric sequence)

  • axis1 == axis3 (symmetric sequence)

For Davenport angles, this last relationship is relaxed [1], and only the consecutive orthogonal axes requirement is maintained.

A slightly modified version of the algorithm from [2] has been used to calculate Davenport angles for the rotation about a given sequence of axes.

Davenport angles, just like Euler angles, suffer from the problem of gimbal lock [3], where the representation loses a degree of freedom and it is not possible to determine the first and third angles uniquely. In this case, a warning is raised (unless the suppress_warnings option is used), and the third angle is set to zero. Note however that the returned angles still represent the correct rotation.

Parameters

axes : array_like, shape (..., [1 or 2 or 3], 3) or (..., 3)

Axis of rotation, if one dimensional. If N dimensional, describes the sequence of axes for rotations, where each axes[..., i, :] is the ith axis. If more than one axis is given, then the second axis must be orthogonal to both the first and third axes.

order : str

If it belongs to the set {'e', 'extrinsic'}, the sequence will be extrinsic. If it belongs to the set {'i', 'intrinsic'}, sequence will be treated as intrinsic.

degrees : bool, optional

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

suppress_warnings : bool, optional

Disable warnings about gimbal lock. Default is False.

Returns

angles : ndarray, shape (..., 3)

Shape depends on shape of inputs used to initialize object. The returned angles are in the range:

  • First angle belongs to (both inclusive)

  • Third angle belongs to (both inclusive)

  • Second angle belongs to a set of size 180°, given by:

    • , if

    • , if

    Here is the angle in that rotates axis 3 onto axis 1 using axis 2 as the rotation vector (all intervals inclusive on both sides).

Examples

from scipy.spatial.transform import Rotation as R
import numpy as np
✓
Davenport angles are a generalization of Euler angles, when we use the canonical basis axes:
ex = [1, 0, 0]
ey = [0, 1, 0]
ez = [0, 0, 1]
✓
Represent a single rotation:
r = R.from_rotvec([0, 0, np.pi/2])
r.as_davenport([ez, ex, ey], 'extrinsic', degrees=True)
r.as_euler('zxy', degrees=True)
r.as_davenport([ez, ex, ey], 'extrinsic', degrees=True).shape
✓
(3,)
Represent a stack of single rotation:
r = R.from_rotvec([[0, 0, np.pi/2]])
r.as_davenport([ez, ex, ey], 'extrinsic', degrees=True)
r.as_davenport([ez, ex, ey], 'extrinsic', degrees=True).shape
✓
(1, 3)
Represent multiple rotations in a single object:
r = R.from_rotvec([
[0, 0, 90],
[45, 0, 0]], degrees=True)
r.as_davenport([ez, ex, ey], 'extrinsic', degrees=True)
r.as_davenport([ez, ex, ey], 'extrinsic', degrees=True).shape
✓
(2, 3)

Aliases

  • scipy.spatial.transform.Rotation.as_davenport