Quaternion Class¶
The Quaternion class provides a compact, singularity-free representation of 3D rotations for spacecraft attitude determination and control.
Quaternion ¶
Represents a quaternion for 3D rotations.
Quaternions provide a compact, singularity-free representation of rotations. The quaternion is stored as [w, x, y, z] where w is the scalar part and [x, y, z] is the vector part.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
w | float | Scalar component | required |
x | float | X component of vector part | required |
y | float | Y component of vector part | required |
z | float | Z component of vector part | required |
Example
Initialize instance.
data property ¶
data: ndarray
Get the quaternion components as a numpy array [w, x, y, z].
Returns:
| Type | Description |
|---|---|
ndarray | numpy.ndarray: 4-element array containing quaternion components |
w property ¶
w: float
Get the scalar (w) component of the quaternion.
Returns:
| Name | Type | Description |
|---|---|---|
float | float | Scalar component |
x property ¶
x: float
Get the x component of the quaternion's vector part.
Returns:
| Name | Type | Description |
|---|---|---|
float | float | X component |
y property ¶
y: float
Get the y component of the quaternion's vector part.
Returns:
| Name | Type | Description |
|---|---|---|
float | float | Y component |
z property ¶
z: float
Get the z component of the quaternion's vector part.
Returns:
| Name | Type | Description |
|---|---|---|
float | float | Z component |
conjugate method descriptor ¶
conjugate() -> Quaternion
Compute the conjugate of the quaternion.
Returns:
| Name | Type | Description |
|---|---|---|
Quaternion | Quaternion | Conjugate quaternion with negated vector part |
from_euler_angle builtin ¶
from_euler_angle(e: EulerAngle) -> Quaternion
Create a quaternion from an Euler angle representation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
e | EulerAngle | Euler angle representation | required |
Returns:
| Name | Type | Description |
|---|---|---|
Quaternion | Quaternion | Equivalent quaternion |
from_euler_axis builtin ¶
from_euler_axis(e: EulerAxis) -> Quaternion
Create a quaternion from an Euler axis representation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
e | EulerAxis | Euler axis representation | required |
Returns:
| Name | Type | Description |
|---|---|---|
Quaternion | Quaternion | Equivalent quaternion |
from_quaternion builtin ¶
from_quaternion(q: Quaternion) -> Quaternion
Create a quaternion from another quaternion (copy constructor).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
q | Quaternion | Source quaternion | required |
Returns:
| Name | Type | Description |
|---|---|---|
Quaternion | Quaternion | New quaternion instance |
from_rotation_matrix builtin ¶
from_rotation_matrix(r: RotationMatrix) -> Quaternion
Create a quaternion from a rotation matrix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
r | RotationMatrix | Rotation matrix | required |
Returns:
| Name | Type | Description |
|---|---|---|
Quaternion | Quaternion | Equivalent quaternion |
from_vector builtin ¶
from_vector(v: ndarray, scalar_first: bool) -> Quaternion
Create a quaternion from a numpy array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v | ndarray | 4-element array containing quaternion components | required |
scalar_first | bool | If True, array is [w, x, y, z], else [x, y, z, w] | required |
Returns:
| Name | Type | Description |
|---|---|---|
Quaternion | Quaternion | New quaternion instance |
inverse method descriptor ¶
inverse() -> Quaternion
Compute the inverse of the quaternion.
Returns:
| Name | Type | Description |
|---|---|---|
Quaternion | Quaternion | Inverse quaternion |
slerp method descriptor ¶
slerp(other: Quaternion, t: float) -> Quaternion
Perform spherical linear interpolation (SLERP) between two quaternions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other | Quaternion | Target quaternion | required |
t | float | Interpolation parameter in [0, 1] | required |
Returns:
| Name | Type | Description |
|---|---|---|
Quaternion | Quaternion | Interpolated quaternion |
to_euler_angle method descriptor ¶
to_euler_angle(order: str) -> EulerAngle
Convert to Euler angle representation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
order | str | Rotation sequence (e.g., "XYZ", "ZYX") | required |
Returns:
| Name | Type | Description |
|---|---|---|
EulerAngle | EulerAngle | Equivalent Euler angles |
to_euler_axis method descriptor ¶
to_euler_axis() -> EulerAxis
Convert to Euler axis representation.
Returns:
| Name | Type | Description |
|---|---|---|
EulerAxis | EulerAxis | Equivalent Euler axis |
to_quaternion method descriptor ¶
to_quaternion() -> Quaternion
Convert to quaternion representation (returns self).
Returns:
| Name | Type | Description |
|---|---|---|
Quaternion | Quaternion | This quaternion |
to_rotation_matrix method descriptor ¶
to_rotation_matrix() -> RotationMatrix
Convert to rotation matrix representation.
Returns:
| Name | Type | Description |
|---|---|---|
RotationMatrix | RotationMatrix | Equivalent rotation matrix |