m2q_c |

Table of contents## Procedurem2q_c ( Matrix to quaternion ) void 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 by a routine in the call tree of this routine. ## 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_ReferencesNone. ## Author_and_InstitutionN.J. Bachman (JPL) J. Diaz del Rio (ODC Space) W.L. Taber (JPL) E.D. Wright (JPL) ## Version-CSPICE Version 1.1.2, 24-AUG-2021 (JDR) Edited the header to comply with NAIF standard. Moved ROTATIONS required reading from -Literature_References to -Required_Reading section. -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) (WLT) Based on SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) ## Index_Entriesmatrix to quaternion |

Fri Dec 31 18:41:09 2021