Skip to content

Attitude Kinematics

quaternion_derivative builtin

quaternion_derivative(q: Quaternion, angular_velocity: ndarray, scalar_first: bool) -> ndarray

Computes the time derivative of an attitude quaternion from the body-frame angular velocity.

Parameters:

Name Type Description Default
q Quaternion

Attitude quaternion transforming frame A to frame B.

required
angular_velocity ndarray

Angular velocity of B relative to A, expressed in B, shape (3,). Units: (rad/s)

required
scalar_first bool

If True, the returned array is [q̇s, q̇1, q̇2, q̇3], else [q̇1, q̇2, q̇3, q̇s]

required

Returns:

Type Description
ndarray

numpy.ndarray: Quaternion derivative, shape (4,), ordered per

ndarray

scalar_first. Not a unit quaternion. Units: (1/s)

Example
1
2
3
4
5
import brahe as bh
import numpy as np

q = bh.Quaternion(1.0, 0.0, 0.0, 0.0)
q_dot = bh.quaternion_derivative(q, np.array([0.0, 0.0, 0.1]), scalar_first=True)
References

J. Diebel, Representing Attitude: Euler Angles, Unit Quaternions, and Rotation Vectors, 2006. Eq. 157.

angular_velocity_from_quaternion_derivative builtin

angular_velocity_from_quaternion_derivative(q: Quaternion, q_dot: ndarray, scalar_first: bool) -> ndarray

Recovers the body-frame angular velocity from an attitude quaternion and its time derivative.

Exact inverse of quaternion_derivative for a unit quaternion whose derivative is tangent to the unit-quaternion manifold. A radial (norm-drift) component of q_dot is projected out, so quaternion derivatives obtained by numerical differentiation or integration are accepted.

Parameters:

Name Type Description Default
q Quaternion

Attitude quaternion transforming frame A to frame B.

required
q_dot ndarray

Quaternion derivative, shape (4,), ordered per scalar_first. Units: (1/s)

required
scalar_first bool

If True, q_dot is [q̇s, q̇1, q̇2, q̇3], else [q̇1, q̇2, q̇3, q̇s]

required

Returns:

Type Description
ndarray

numpy.ndarray: Angular velocity of B relative to A, expressed in B,

ndarray

shape (3,). Units: (rad/s)

Example
1
2
3
4
5
6
7
import brahe as bh
import numpy as np

q = bh.Quaternion(1.0, 0.0, 0.0, 0.0)
omega = np.array([0.02, -0.01, 0.3])
q_dot = bh.quaternion_derivative(q, omega, scalar_first=True)
recovered = bh.angular_velocity_from_quaternion_derivative(q, q_dot, scalar_first=True)
References

J. Diebel, Representing Attitude: Euler Angles, Unit Quaternions, and Rotation Vectors, 2006. Eq. 147.

euler_rates_to_angular_velocity builtin

euler_rates_to_angular_velocity(angles: EulerAngle, rates: ndarray) -> ndarray

Converts Euler-angle rates to the body-frame angular velocity.

Parameters:

Name Type Description Default
angles EulerAngle

Euler angles in brahe application order. Units: (rad)

required
rates ndarray

Angle rates (φ̇, θ̇, ψ̇) in the same order as angles, shape (3,). Units: (rad/s)

required

Returns:

Type Description
ndarray

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

ndarray

expressed in B, shape (3,). Units: (rad/s)

Example
1
2
3
4
5
6
import brahe as bh
import numpy as np

angles = bh.EulerAngle(bh.EulerAngleOrder.ZYX, 0.0, 0.0, 0.0, bh.AngleFormat.RADIANS)
rates = np.array([0.1, -0.2, 0.3])
omega = bh.euler_rates_to_angular_velocity(angles, rates)
References

J. Diebel, Representing Attitude: Euler Angles, Unit Quaternions, and Rotation Vectors, 2006. Eqs. 38 and 40.

angular_velocity_to_euler_rates builtin

angular_velocity_to_euler_rates(angles: EulerAngle, angular_velocity: ndarray) -> ndarray

Converts body-frame angular velocity to Euler-angle rates.

Exact inverse of euler_rates_to_angular_velocity away from the sequence's gimbal-lock singularity. Sequences with three distinct axes are singular at θ = ±90°; sequences that repeat the first axis are singular at θ = 0° and θ = 180°. This function raises within roughly 1e-6 rad of either condition.

Parameters:

Name Type Description Default
angles EulerAngle

Euler angles in brahe application order. Units: (rad)

required
angular_velocity ndarray

Body-frame angular velocity, shape (3,). Units: (rad/s)

required

Returns:

Type Description
ndarray

numpy.ndarray: Angle rates (φ̇, θ̇, ψ̇) in the same order as angles,

ndarray

shape (3,). Units: (rad/s)

Raises:

Type Description
BraheError

If angles is at or near the sequence's gimbal-lock singularity.

Example
1
2
3
4
5
6
7
import brahe as bh
import numpy as np

angles = bh.EulerAngle(bh.EulerAngleOrder.ZXZ, 0.5, 0.8, -1.2, bh.AngleFormat.RADIANS)
rates = np.array([0.02, 0.13, -0.07])
omega = bh.euler_rates_to_angular_velocity(angles, rates)
recovered = bh.angular_velocity_to_euler_rates(angles, omega)
References

J. Diebel, Representing Attitude: Euler Angles, Unit Quaternions, and Rotation Vectors, 2006. Eq. 40.

See Also