dcm2qter.m

From Spinach Documentation Wiki
Jump to: navigation, search

Converts a direction cosine matrix in the active convention of euler2dcm.m function into a unit quaternion. The four Shepperd invariants 1+dxx+dyy+dzz, 1+dxx-dyy-dzz, 1-dxx+dyy-dzz, and 1-dxx-dyy+dzz are formed first, and the conversion proceeds through the largest of them; this keeps the square root and the division away from zero for every rotation, including the half-turns at which the naive trace formula fails. The sign of the result is then flipped if necessary to give a non-negative scalar part, and the four components are divided by the Euclidean norm of the quaternion. The input is checked for orthogonality and for a unit determinant to a tolerance of 1e-6.

Syntax

    q=dcm2qter(dcm)

Parameters

    dcm - directional cosine matrix, a 3x3 orthogonal
          matrix with unit determinant

Outputs

    q - structure with four scalar fields q.u, q.i, q.j,
        q.k giving the four components of the quaternion,
        normalised to q.u greater than or equal to zero

Notes

Note: quaternions double-cover rotations; of the two candidates q and -q this function returns the one with the non-negative scalar part.

See also

euler2dcm.m, dcm2euler.m, dcm2wigner.m, anax2quat.m, quat2anax.m, Rotation conventions

Version 2.13, authors: Ilya Kuprov