Skip to content
This repository has been archived by the owner on Dec 24, 2023. It is now read-only.

Quaternion helper functions #5

Open
ChristopherRabotin opened this issue Dec 13, 2021 · 0 comments
Open

Quaternion helper functions #5

ChristopherRabotin opened this issue Dec 13, 2021 · 0 comments
Labels
proposed A proposed functionality supported-functions Related to the functions provided by ANISE

Comments

@ChristopherRabotin
Copy link
Member

ChristopherRabotin commented Dec 13, 2021

Allows all sorts of computations with quaternions. We should look at nalgebra's quite complete implementation of quaternions of this (note however that they use the {i,j,k,w} notation, which is not common in the aerospace industry).

Proposed signatures

This is only available in the algorithms module.

Quaternion definition

/// Defines a quaternion where `w` corresponds to the scalar value sin(Φ/2) and X, Y, Z correspond to the vector part.
pub struct Quaternion {
  pub w: f64,
  pub x: f64,
  pub y: f64,
  pub z: f64,
}

Conversion to/from a direct cosine matrix

Question: should this function return an error if the provided matrix is not a valid DCM? This can be checked by the following assertion being violated: C*C^T = I_3x3 . However, there are rounding errors where the resulting DCM is not exactly identity.

Recommendation: provide two functions: dcm_to_quat and dcm_to_quat_unchecked where the unchecked does not check that the input DCM is valid. We could also provide both an implementation of TryFrom and From which would respectively use the "checked" and "unchecked" versions of the function. Moreover, providing a From implementation will automatically provide the Into implementation, allowing for infallible conversion from a quaternion to a Matrix3 (cf. docs).

/// Try to convert a 3x3 matrix into a quaternion. Will return an error if the matrix is not a valid direct cosine matrix
impl TryFrom<&Matrix3<f64>> to Quaterion {
  type Error = AniseError;
}
/// The following function is actually called. 
pub fn dcm_to_quat(dcm: &Matrix3<f64>) -> Result<Quaternion, AniseError> {}

Combine rotations

Defines the operation q_A2C = q_A2B + q_B2C . This operation cannot fail.

impl Add for Quaternion {}

Inverse rotations

Defines the operation q_A2C = -q_C2A. This operation cannot fail.

impl Neg for Quaternion {}

Rotate a vector by this quaternion

Defines the rotation of a vector by the provided quaternion such that ^{A}v = q_B2A * ^{B}v , where "^{A}v" means "vector in the A frame"

impl Mul<Vector3> for Quaternion {}

Extract the principal rotation vector and the rotation angle

This can be useful for analysis.

impl Quaternion {

  pub fn prv(&self) -> Vector3 {}

  pub fn angle_deg(&self) -> f64 {}

}
@ChristopherRabotin ChristopherRabotin added supported-functions Related to the functions provided by ANISE proposed A proposed functionality labels Dec 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
proposed A proposed functionality supported-functions Related to the functions provided by ANISE
Projects
None yet
Development

No branches or pull requests

1 participant