Skip to content

Quaternion

Quaternion attitude representation.

Provides the Quaternion class representing a rotation as a unit quaternion in scalar-first convention [w, x, y, z].

The quaternion is normalized on construction. This class serves as the central hub for attitude conversions -- most cross-type conversions route through Quaternion (matching the Rust brahe architecture).

Quaternion

Unit quaternion representing a 3D rotation.

Internal storage is a shape (4,) array in scalar-first order [w, x, y, z]. The quaternion is normalized on construction.

This class is registered as a JAX pytree with the data array as the sole leaf and no auxiliary data.

Parameters:

Name Type Description Default
s float

Scalar (real) component.

required
v1 float

First vector (imaginary) component.

required
v2 float

Second vector (imaginary) component.

required
v3 float

Third vector (imaginary) component.

required

w property

Scalar component.

x property

First vector component.

y property

Second vector component.

z property

Third vector component.

__mul__(other)

Hamilton product (quaternion * quaternion).

conjugate()

Return the conjugate (adjoint) quaternion.

For a unit quaternion, the conjugate equals the inverse.

Returns:

Name Type Description
Quaternion Quaternion

Conjugate quaternion [w, -x, -y, -z].

from_euler_angle(e) classmethod

Create from an EulerAngle.

Parameters:

Name Type Description Default
e EulerAngle

Source euler angle.

required

Returns:

Name Type Description
Quaternion Quaternion

Equivalent quaternion.

from_euler_axis(ea) classmethod

Create from an EulerAxis.

Parameters:

Name Type Description Default
ea EulerAxis

Source euler axis.

required

Returns:

Name Type Description
Quaternion Quaternion

Equivalent quaternion.

from_quaternion(q) classmethod

Create from another Quaternion.

Parameters:

Name Type Description Default
q Quaternion

Source quaternion.

required

Returns:

Name Type Description
Quaternion Quaternion

Copy.

from_rotation_matrix(r) classmethod

Create from a RotationMatrix.

Parameters:

Name Type Description Default
r RotationMatrix

Source rotation matrix.

required

Returns:

Name Type Description
Quaternion Quaternion

Equivalent quaternion.

from_vector(v, scalar_first=True) classmethod

Create from a 4-element vector.

Parameters:

Name Type Description Default
v Array

Array-like of shape (4,).

required
scalar_first bool

If True, v = [w, x, y, z]. If False, v = [x, y, z, w].

True

Returns:

Name Type Description
Quaternion Quaternion

New normalized quaternion.

inverse()

Return the multiplicative inverse.

For a unit quaternion this is the conjugate; for non-unit quaternions the conjugate is divided by the squared norm.

Returns:

Name Type Description
Quaternion Quaternion

Inverse quaternion.

norm()

Return the Euclidean norm.

Returns:

Type Description
Array

jax.Array: Scalar norm.

normalize()

Return a new normalized quaternion.

Returns:

Name Type Description
Quaternion Quaternion

Unit quaternion.

slerp(other, t)

Spherical linear interpolation.

Parameters:

Name Type Description Default
other Quaternion

Target quaternion.

required
t float

Interpolation parameter in [0, 1]. t=0 returns self, t=1 returns other.

required

Returns:

Name Type Description
Quaternion Quaternion

Interpolated quaternion.

to_euler_angle(order)

Convert to EulerAngle with specified rotation sequence.

Goes through the rotation matrix representation (matching Rust).

Parameters:

Name Type Description Default
order EulerAngleOrder

EulerAngleOrder specifying the rotation sequence.

required

Returns:

Name Type Description
EulerAngle EulerAngle

Equivalent euler angle.

to_euler_axis()

Convert to EulerAxis.

Returns:

Name Type Description
EulerAxis EulerAxis

Equivalent euler axis.

to_quaternion()

Return a copy.

Returns:

Name Type Description
Quaternion Quaternion

New quaternion with same data.

to_rotation_matrix()

Convert to RotationMatrix.

Returns:

Name Type Description
RotationMatrix RotationMatrix

Equivalent rotation matrix.

to_vector(scalar_first=True)

Return the quaternion as a 4-element vector.

Parameters:

Name Type Description Default
scalar_first bool

If True, return [w, x, y, z]. If False, return [x, y, z, w].

True

Returns:

Type Description
Array

jnp.ndarray: Array of shape (4,).