Documentation Index
Fetch the complete documentation index at: https://docs.generalrobotics.dev/llms.txt
Use this file to discover all available pages before exploring further.
Orientation
Inherits from: object
A class to represent the orientation as a quaternion
Attributes:
x (float): x component of quaternion
y (float): y component of quaternion
z (float): z component of quaternion
w (float): w component of quaternion (scalar)
Can be initialized with either quaternion components or Euler angles
init
Orientation.__init__(x: float, y: float, z: float, w: float)
Initialize an Orientation with quaternion components.
x component of quaternion
y component of quaternion
z component of quaternion
w component of quaternion (scalar)
init
Orientation.__init__(roll: float, pitch: float, yaw: float)
Initialize an Orientation with Euler angles.
Rotation around x-axis in radians
Rotation around y-axis in radians
Rotation around z-axis in radians
init
Orientation.__init__(rotation_matrix: Union[np.ndarray, list])
Initialize an Orientation with a rotation matrix.
rotation_matrix (Union[np.ndarray, list])
Union[np.ndarray, list]
required
3x3 rotation matrix or 9/16-element list
init
Orientation.__init__(quaternion: Union[list, np.ndarray])
Initialize an Orientation with a quaternion array.
quaternion (Union[list, np.ndarray])
Union[list, np.ndarray]
required
4-element array [x, y, z, w]
init
Orientation.__init__(x: Union[float, int, np.ndarray, list], y: Union[float, int] = None, z: Union[float, int] = None, w: Optional[Union[float, int]] = None)
Initialize an Orientation object.
This constructor supports multiple initialization methods:
- Using quaternion components (x, y, z, w)
- Using Euler angles (roll, pitch, yaw) where the first three arguments
are interpreted as roll, pitch, and yaw respectively
- Using a rotation matrix (3x3 numpy array or list)
- Using a quaternion array (4-element list or numpy array)
x (Union[float, int, np.ndarray, list])
Union[float, int, np.ndarray, list]
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 (Optional[Union[float, int]])
Optional[Union[float, int]]
w component of quaternion. When None, x, y, z are interpreted as Euler angles.
If the provided arguments don’t match any initialization pattern
Quaternion components are automatically normalized to ensure a unit quaternion.
conjugate
Return the conjugate of the quaternion (-x, -y, -z, w).
For a unit quaternion, the conjugate is its inverse.
New orientation representing the conjugate.
normalize
Return a normalized version of this quaternion
New orientation with normalized quaternion components
to_euler
Orientation.to_euler(order: str = 'xyz') -> tuple[float, float, float]
Convert quaternion to Euler angles.
Order of rotations. Defaults to “xyz”. Supported orders include “xyz”, “zyx”, “yzx”, etc.
returns
tuple[float, float, float]
to_matrix
Orientation.to_matrix() -> np.ndarray
Convert quaternion to a rotation matrix
to_axis_angle
Orientation.to_axis_angle(degrees: bool = False) -> np.ndarray
Convert quaternion to axis-angle representation.
If True, the angle is returned in degrees. Defaults to False.
3 dimensional vector which is co-directional to the axis of rotation and whose norm gives the angle of rotation.
to_dict
Orientation.to_dict() -> dict
Serialize to dictionary for JSON transfer
from_dict
Orientation.from_dict(data: dict) -> 'Orientation'
Deserialize from dictionary