Attitude Representations¶
The astrojax.attitude_representations module provides four
interconvertible 3D rotation representations, elementary rotation
functions, and pure conversion kernels. All types use JAX
primitives and are compatible with jax.jit, jax.vmap, and
jax.grad.
Representation Types¶
| Type | Internal Storage | Degrees of Freedom | Page |
|---|---|---|---|
Quaternion |
[w, x, y, z] shape (4,) |
4 (unit constraint) | Quaternion |
RotationMatrix |
shape (3, 3) |
9 (SO(3) constraint) | Rotation Matrix |
EulerAngle |
(order, phi, theta, psi) |
3 angles + order | Euler Angles |
EulerAxis |
(axis(3,), angle) |
3 axis + 1 angle | Euler Axis |
Additional Components¶
| Component | Description | Page |
|---|---|---|
| Elementary Rotations | Rx, Ry, Rz axis-aligned rotation matrix constructors |
Elementary Rotations |
| Conversions | Pure conversion kernels operating on raw JAX arrays | Conversions |
Conversion Graph¶
All four types provide to_* instance methods and from_* class
methods for full interconvertibility. Most conversions route through
the quaternion representation internally:
from astrojax import Quaternion, RotationMatrix, EulerAngle, EulerAngleOrder, EulerAxis
q = Quaternion(0.675, 0.42, 0.5, 0.71)
# Quaternion -> RotationMatrix -> EulerAngle -> EulerAxis -> Quaternion
r = q.to_rotation_matrix()
e = r.to_euler_angle(EulerAngleOrder.ZYX)
ea = e.to_euler_axis()
q_back = ea.to_quaternion()
JAX Compatibility¶
All four types are registered as JAX pytrees and work with jax.jit:
import jax
@jax.jit
def rotate_and_convert(q):
r = q.to_rotation_matrix()
return r.to_euler_angle(EulerAngleOrder.XYZ)
q = Quaternion(0.675, 0.42, 0.5, 0.71)
e = rotate_and_convert(q)
The pytree structure for each type:
| Type | Leaves | Auxiliary |
|---|---|---|
Quaternion |
(data,) |
None |
RotationMatrix |
(data,) |
None |
EulerAngle |
(phi, theta, psi) |
order |
EulerAxis |
(axis, angle) |
None |