Skip to content

AttitudeTrajectory

AttitudeTrajectory is a chronologically sorted collection of AttitudeState samples (a unit quaternion plus an optional body angular velocity) relating two ReferenceFrame endpoints, with slerp, linear, and Lagrange interpolation.

AttitudeTrajectory has the same API as Trajectory, plus quaternion-aware interpolation and the OrientationProvider accessors (quaternion, angular_velocity, euler_angle, euler_axis, rotation_matrix) documented below.

AttitudeTrajectory

AttitudeTrajectory(frame_a: ReferenceFrame, frame_b: ReferenceFrame)

A chronologically sorted collection of AttitudeState samples relating two ReferenceFrame endpoints.

Every stored quaternion represents the attitude of frame_b relative to frame_a. All states in a trajectory must uniformly carry angular velocity or uniformly omit it; add rejects a state that would mix the two.

Parameters:

Name Type Description Default
frame_a ReferenceFrame

Frame endpoint A

required
frame_b ReferenceFrame

Frame endpoint B (stored quaternions rotate from frame_a to frame_b)

required
Example
1
2
3
4
5
6
7
8
9
import brahe as bh
from brahe.trajectories import AttitudeTrajectory

traj = bh.AttitudeTrajectory(
    bh.ReferenceFrame.celestial(bh.CelestialFrame.GCRF),
    bh.ReferenceFrame.body(None, bh.BodyFrame.SC_BODY("1")),
)
epoch = bh.Epoch.from_datetime(2024, 1, 1, 0, 0, 0.0, 0.0, bh.TimeSystem.UTC)
traj.add(epoch, bh.Quaternion(1.0, 0.0, 0.0, 0.0))

Initialize instance.

end_epoch property

end_epoch: Any

Epoch | None: Last epoch if the trajectory is not empty, None otherwise

frame_a property

frame_a: Any

ReferenceFrame: Frame endpoint A

frame_b property

frame_b: Any

ReferenceFrame: Frame endpoint B (stored quaternions rotate from frame_a to frame_b)

has_rates property

has_rates: Any

bool: True if the trajectory is non-empty and its states carry angular velocity

interpolation_degree property

interpolation_degree: Any

int | None: Polynomial degree for Lagrange interpolation, or None unless interpolation_method is "LAGRANGE"

interpolation_method property

interpolation_method: Any

str: Current interpolation method - "SLERP", "LINEAR", or "LAGRANGE"

metadata property

metadata: dict

dict: Trajectory metadata key-value pairs

name property

name: Any

str | None: Trajectory name

start_epoch property

start_epoch: Any

Epoch | None: First epoch if the trajectory is not empty, None otherwise

add method descriptor

add(epoch: Epoch, quaternion: Quaternion, angular_velocity: ndarray | None = None) -> Any

Add an attitude state at the given epoch.

Parameters:

Name Type Description Default
epoch Epoch

Epoch of the new state

required
quaternion Quaternion

Unit quaternion attitude, frame A to frame B

required
angular_velocity ndarray | None

Angular velocity of frame B relative to frame A, expressed in frame B. Units: rad/s. Must be uniformly present or uniformly absent across every state added to this trajectory.

None

Raises:

Type Description
BraheError

If the new state's angular-velocity presence does not match the trajectory's existing states.

angular_velocity method descriptor

angular_velocity(epoch: Epoch) -> Any

Return the body angular velocity at the given epoch.

Returns None when the trajectory carries no rate data (see has_rates); that is not an error.

Parameters:

Name Type Description Default
epoch Epoch

Target epoch

required

Returns:

Type Description
Any

numpy.ndarray | None: Angular velocity of frame B relative to frame A, expressed

Any

in frame B, in rad/s, or None if the trajectory carries no rate data

Raises:

Type Description
BraheError

If the epoch lies outside the trajectory's coverage, or the trajectory is empty

euler_angle method descriptor

euler_angle(epoch: Epoch, order: EulerAngleOrder) -> EulerAngle

Return the attitude at the given epoch as Euler angles in the requested sequence.

Parameters:

Name Type Description Default
epoch Epoch

Target epoch

required
order EulerAngleOrder

Euler angle rotation sequence

required

Returns:

Name Type Description
EulerAngle EulerAngle

Euler angles (radians) at epoch in the requested sequence

Raises:

Type Description
BraheError

If the epoch lies outside the trajectory's coverage, or the trajectory is empty

euler_axis method descriptor

euler_axis(epoch: Epoch) -> EulerAxis

Return the attitude at the given epoch as an Euler axis (axis-angle).

Parameters:

Name Type Description Default
epoch Epoch

Target epoch

required

Returns:

Name Type Description
EulerAxis EulerAxis

Unit rotation axis and angle (radians) at epoch

Raises:

Type Description
BraheError

If the epoch lies outside the trajectory's coverage, or the trajectory is empty

quaternion method descriptor

quaternion(epoch: Epoch) -> Quaternion

Return the attitude quaternion at the given epoch using the configured interpolation method.

Parameters:

Name Type Description Default
epoch Epoch

Target epoch

required

Returns:

Name Type Description
Quaternion Quaternion

Unit quaternion attitude, frame A to frame B, at epoch

Raises:

Type Description
BraheError

If the epoch lies outside the trajectory's coverage, or the trajectory is empty

rotation_matrix method descriptor

rotation_matrix(epoch: Epoch) -> RotationMatrix

Return the attitude at the given epoch as a rotation matrix (DCM).

Parameters:

Name Type Description Default
epoch Epoch

Target epoch

required

Returns:

Name Type Description
RotationMatrix RotationMatrix

3x3 direction cosine matrix at epoch

Raises:

Type Description
BraheError

If the epoch lies outside the trajectory's coverage, or the trajectory is empty

set_interpolation_method method descriptor

set_interpolation_method(method: str, degree: int | None = None) -> Any

Set the interpolation method used for state retrieval at arbitrary epochs.

Parameters:

Name Type Description Default
method str

Interpolation method - "SLERP" (default), "LINEAR", or "LAGRANGE" (case-insensitive)

required
degree int | None

Polynomial degree, required iff method is "LAGRANGE"

None

Raises:

Type Description
ValueError

If method is not recognized, or degree is missing for "LAGRANGE"


AttitudeState

AttitudeState(quaternion: Quaternion, angular_velocity: ndarray | None = None)

A single attitude sample: a unit quaternion and an optional body rate.

The quaternion represents the attitude of frame B relative to frame A (see AttitudeTrajectory). When present, angular_velocity is the angular velocity of frame B relative to frame A, expressed in frame B, in rad/s.

Parameters:

Name Type Description Default
quaternion Quaternion

Unit quaternion attitude, frame A to frame B

required
angular_velocity ndarray | None

Angular velocity of frame B relative to frame A, expressed in frame B. Units: rad/s

None
Example
1
2
3
import brahe as bh
from brahe.trajectories import AttitudeState
state = AttitudeState(bh.Quaternion(1.0, 0.0, 0.0, 0.0))

Initialize instance.

angular_velocity property

angular_velocity: Any

numpy.ndarray | None: Angular velocity of frame B relative to frame A, expressed in frame B, in rad/s, or None if this state does not carry rate data

quaternion property

quaternion: Any

Quaternion: Unit quaternion attitude, frame A to frame B


See Also