Skip to main content
A class to represent the orientation as a quaternion

Fields

float
x component of quaternion
float
y component of quaternion
float
z component of quaternion
float
w component of quaternion (scalar) Can be initialized with either quaternion components or Euler angles

Constructor

Signature
Initialize an Orientation object. This constructor supports multiple initialization methods:
  1. Using quaternion components (x, y, z, w)
  2. Using Euler angles (roll, pitch, yaw) where the first three arguments are interpreted as roll, pitch, and yaw respectively
  3. Using a rotation matrix (3x3 numpy array or list)
  4. Using a quaternion array (4-element list or numpy array)
required
x component of quaternion, roll angle, rotation matrix, or quaternion array
y component of quaternion or pitch angle. Ignored when x is an array.
z component of quaternion or yaw angle. Ignored when x is an array.
w component of quaternion. When None, x, y, z are interpreted as Euler angles.

Methods

conjugate()

Signature
Return the conjugate of the quaternion (-x, -y, -z, w). For a unit quaternion, the conjugate is its inverse. Returns: Orientation: New orientation representing the conjugate.

from_dict()

Signature
Deserialize from dictionary

normalize()

Signature
Return a normalized version of this quaternion Returns: Orientation: New orientation with normalized quaternion components

to_axis_angle()

Signature
Convert quaternion to axis-angle representation.
default:"False"
If True, the angle is returned in degrees. Defaults to False.
Returns: np.ndarray: 3 dimensional vector which is co-directional to the axis of rotation and whose norm gives the angle of rotation.

to_dict()

Signature
Serialize to dictionary for JSON transfer

to_euler()

Signature
Convert quaternion to Euler angles.
default:"'xyz'"
Order of rotations. Defaults to “xyz”. Supported orders include “xyz”, “zyx”, “yzx”, etc.
Returns: tuple[float, float, float]: Tuple of (roll, pitch, yaw) in radians.

to_matrix()

Signature
Convert quaternion to a rotation matrix Returns: np.ndarray: 3x3 rotation matrix

Example