archimedes.spatial.EulerAnglesΒΆ

class archimedes.spatial.EulerAngles(array: ndarray, seq: str = 'xyz')ΒΆ

Euler angle representation of a rotation in 3 dimensions

Parameters:
  • angles (array_like) – Euler angles in radians

  • seq (str, optional) – Sequence of axes for Euler angles (up to length 3). Each character must be one of β€˜x’, β€˜y’, β€˜z’ (extrinsic) or β€˜X’, β€˜Y’, β€˜Z’ (intrinsic). Default is β€˜xyz’.

arrayΒΆ

Underlying array of Euler angles.

Type:

np.ndarray

seqΒΆ

Sequence of axes for Euler angles.

Type:

str

Examples

>>> from archimedes.spatial import EulerAngles
>>> import numpy as np

Consider a right-handed rotation of 90 degrees about the z-axis. This corresponds to a single yaw rotation:

>>> euler = EulerAngles(np.deg2rad(90), 'z')

This can be converted to other representations:

>>> euler.as_matrix()
array([[ 6.123234e-17,  1.000000e+00,  0.000000e+00],
   [-1.000000e+00,  6.123234e-17,  0.000000e+00],
   [ 0.000000e+00,  0.000000e+00,  1.000000e+00]])
>>> np.rad2deg(euler.as_euler('xyx'))  # Roll-pitch-roll sequence
array([-90.,  90.,  90.])
>>> euler.as_quat()
Quaternion([0.70710678 0.         0.         0.70710678])

The associated rotation matrix can be used to change coordinate systems. If the Euler sequence represents the orientation of a frame B relative to a frame A, then the rotation matrix transforms vectors from frame A to frame B:

>>> v_A = np.array([1, 0, 0])  # Vector in frame A
>>> R_BA = euler.as_matrix()
>>> R_BA @ v_A  # Vector in frame B
[6.12323e-17, -1, 0]

The kinematics method can be used to compute the time derivative of the Euler angles given the angular velocity in the body frame. Note that Euler kinematics are currently only supported for the β€œxyz” sequence (standard roll-pitch-yaw):

>>> w_B = np.array([0, 0, np.pi/2])  # 90 deg/s about z-axis
>>> rpy = EulerAngles([0.1, 0.2, 0.3], "xyz")
>>> rpy.kinematics(w_B)
EulerAngles([ 0.31682542 -0.15681796  1.59473746], seq='xyz')

Be careful with the kinematics output; this is expressed as an EulerAngles instance for consistency with ODE solvers but represents rotation _rates_. Trying to apply this output as a rotation or convert to a DCM will not produce meaningful results.

See also

Quaternion

Quaternion representation of rotation in 3D

RigidBody

Rigid body dynamics supporting EulerAngles attitude representation

euler_to_dcm

Directly calculate rotation matrix from roll-pitch-yaw angles

euler_kinematics

Transform roll-pitch-yaw rates to body-frame angular velocity

__init__(array: ndarray, seq: str = 'xyz') NoneΒΆ

Methods

__init__(array[, seq])

as_euler([seq])

Return the Euler angles in a different sequence of axes.

as_matrix()

Convert the Euler angles to a direction cosine matrix (DCM).

as_quat()

Return the corresponding Quaternion representation.

from_euler(euler[, seq])

Return an EulerAngles instance from another EulerAngles instance.

from_quat(quat[, seq])

Create EulerAngles from a Quaternion.

identity([seq])

Return the identity EulerAngles (zero rotation).

inv()

Return the inverse (conjugate) of this Euler angle rotation.

kinematics(w_B)

Compute the time derivative of the Euler angles given angular velocity.

replace(**updates)

Returns a new object replacing the specified fields with new values.

Attributes