Function to_dcm

Source
pub fn to_dcm<T>(q: Quaternion<T>) -> DCM<T>
where T: Float,
Expand description

Convert a Versor to a DCM representing the q v q* rotation (Point Rotation - Frame Fixed).

When convert to a DCM representing the q* v q rotation (Frame Rotation - Point Fixed), do the following:

let dcm = to_dcm( conj(q) );

ยงExamples

// Make these as you like.
let v = [1.0, 0.5, -8.0];
let q = from_axis_angle([0.2, 1.0, -2.0], PI/4.0);
 
// --- Point rotation --- //
{
    let m = to_dcm(q);
 
    let rm = matrix_product(m, v);
    let rq = point_rotation(q, v);
    assert!( (rm[0] - rq[0]).abs() < 1e-12 );
    assert!( (rm[1] - rq[1]).abs() < 1e-12 );
    assert!( (rm[2] - rq[2]).abs() < 1e-12 );
}
 
// --- Frame rotation --- //
{
    let m = to_dcm( conj(q) );
 
    let rm = matrix_product(m, v);
    let rq = frame_rotation(q, v);
    assert!( (rm[0] - rq[0]).abs() < 1e-12 );
    assert!( (rm[1] - rq[1]).abs() < 1e-12 );
    assert!( (rm[2] - rq[2]).abs() < 1e-12 );
}