m2q_c |

## Procedurevoid m2q_c ( ConstSpiceDouble r[3][3], SpiceDouble q[4] ) ## AbstractFind a unit quaternion corresponding to a specified rotation matrix. ## Required_ReadingROTATION ## KeywordsMATH MATRIX ROTATION ## Brief_I/OVariable I/O Description -------- --- -------------------------------------------------- r I A rotation matrix. q O A unit quaternion representing `r'. ## Detailed_Inputr is a rotation matrix. ## Detailed_Outputq is a unit-length SPICE-style quaternion representing `r'. See the discussion of quaternion styles in Particulars below. `q' is a 4-dimensional vector. If `r' rotates vectors in the counterclockwise sense by an angle of `theta' radians about a unit vector `a', where 0 < theta < pi - - then letting h = theta/2, q = ( cos(h), sin(h)a , sin(h)a , sin(h)a ). 1 2 3 The restriction that `theta' must be in the range [0, pi] determines the output quaternion `q' uniquely except when theta = pi; in this special case, both of the quaternions q = ( 0, a , a , a ) 1 2 3 and q = ( 0, -a , -a , -a ) 1 2 3 are possible outputs. ## ParametersNone. ## Exceptions1) If `r' is not a rotation matrix, the error SPICE(NOTAROTATION) is signaled. ## FilesNone. ## ParticularsA unit quaternion is a 4-dimensional vector for which the sum of the squares of the components is 1. Unit quaternions can be used to represent rotations in the following way: given a rotation angle `theta', where 0 < theta < pi - - and a unit vector `a', we can represent the transformation that rotates vectors in the counterclockwise sense by theta radians about `a' using the quaternion `q', where q = ( cos(theta/2), sin(theta/2)a , sin(theta/2)a , sin(theta/2)a ) 1 2 3 As mentioned in Detailed Output, our restriction on the range of `theta' determines `q' uniquely, except when theta = pi. The CSPICE routine q2m_c is an one-sided inverse of this routine: given any rotation matrix `r', the calls ## Examples1) A case amenable to checking by hand calculation: To convert the rotation matrix +- -+ | 0 1 0 | | | r = | -1 0 0 | | | | 0 0 1 | +- -+ also represented as [ pi/2 ] 3 to a quaternion, we can use the code fragment rotate_c ( halfpi_c(), 3, r ); ## RestrictionsNone. ## Literature_ReferencesNAIF document 179.0, "Rotations and their Habits", by W. L. Taber. ## Author_and_InstitutionN.J. Bachman (JPL) E.D. Wright (JPL) ## Version-CSPICE Version 1.1.1, 27-FEB-2008 (NJB) Updated header; added information about SPICE quaternion conventions. Made minor edits throughout header. -CSPICE Version 1.1.0, 21-OCT-1998 (NJB) Made input matrix const. -CSPICE Version 1.0.1, 13-FEB-1998 (EDW) Minor corrections to header. -CSPICE Version 1.0.0, 08-FEB-1998 (NJB) Based on SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) ## Index_Entriesmatrix to quaternion |

Wed Apr 5 17:54:38 2017