archimedes.spatial.Attitude¶

class archimedes.spatial.Attitude(*args, **kwargs)¶

Protocol for attitude representations.

This protocol defines the interface that all attitude representation classes must implement. An attitude representation class encapsulates the orientation of a rigid body in 3D space and provides methods for common operations such as conversion to/from other representations and kinematic models.

Methods

as_matrix()

Convert the attitude to a direction cosine matrix (DCM).

inv()

Compute the inverse of the rotation corresponding to the attitude.

kinematics(w_B)

Compute the time derivative of the attitude given angular velocity.

__init__(*args, **kwargs)¶
as_matrix() → ndarray¶

Convert the attitude to a direction cosine matrix (DCM).

If the attitude represents the orientation of a body A relative to a frame B, then this method returns the matrix R_BA that transforms vectors from frame A to frame B. Specifically, for a vector v_A expressed in frame A, the corresponding vector in frame B is given by v_B = R_BA @ v_A.

The inverse transformation can be obtained by transposing this matrix: R_AB = R_BA.T.

Return type:

A 3x3 numpy array representing the DCM.

inv() → Attitude¶

Compute the inverse of the rotation corresponding to the attitude.

Returns:

A new attitude instance representing the inverse rotation.

Return type:

Attitude

kinematics(w_B: ndarray) → Attitude¶

Compute the time derivative of the attitude given angular velocity.

CAUTION: This method returns the time derivative of the attitude, which is represented with the same data structure for consistency with ODE solving - but this return is not itself a valid rotation representation until integrated in time. Hence, the output of kinematics should never be converted to a different attitude representation or rotation matrix.

Parameters:

w_B (np.ndarray) – Angular velocity vector expressed in the body frame B.

Returns:

The time derivative of the attitude representation.

Return type:

Attitude