Skip to main content

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.
Arguments
x (float)
float
required
x component of quaternion
y (float)
float
required
y component of quaternion
z (float)
float
required
z component of quaternion
w (float)
float
required
w component of quaternion (scalar)

init

Orientation.__init__(roll: float, pitch: float, yaw: float)
Initialize an Orientation with Euler angles.
Arguments
roll (float)
float
required
Rotation around x-axis in radians
pitch (float)
float
required
Rotation around y-axis in radians
yaw (float)
float
required
Rotation around z-axis in radians

init

Orientation.__init__(rotation_matrix: Union[np.ndarray, list])
Initialize an Orientation with a rotation matrix.
Arguments
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.
Arguments
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:
  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)
Arguments
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 (Union[float, int])
Union[float, int]
y component of quaternion or pitch angle. Ignored when x is an array.
z (Union[float, int])
Union[float, int]
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.
Raises
ValueError
If the provided arguments don’t match any initialization pattern
Note
Quaternion components are automatically normalized to ensure a unit quaternion.

conjugate

Orientation.conjugate()
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.

normalize

Orientation.normalize()
Return a normalized version of this quaternion
Returns
Orientation
New orientation with normalized quaternion components

to_euler

Orientation.to_euler(order: str = 'xyz') -> tuple[float, float, float]
Convert quaternion to Euler angles.
Arguments
order (str)
str
Order of rotations. Defaults to “xyz”. Supported orders include “xyz”, “zyx”, “yzx”, etc.
Returns
returns
tuple[float, float, float]

to_matrix

Orientation.to_matrix() -> np.ndarray
Convert quaternion to a rotation matrix
Returns
np.ndarray
np.ndarray
3x3 rotation matrix

to_axis_angle

Orientation.to_axis_angle(degrees: bool = False) -> np.ndarray
Convert quaternion to axis-angle representation.
Arguments
degrees (bool)
bool
If True, the angle is returned in degrees. Defaults to False.
Returns
np.ndarray
np.ndarray
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
Returns
returns
dict

from_dict

Orientation.from_dict(data: dict) -> 'Orientation'
Deserialize from dictionary
Arguments
data (dict)
dict
required
No description provided.
Returns
returns
'Orientation'