CSPICE_M2Q calculates a unit quaternion corresponding to a
specified 3x3 double precision, rotation matrix.
For important details concerning this module's function, please refer to
the CSPICE routine m2q_c.
Given:
r a 3x3 double precision rotation matrix
the call:
cspice_m2q, r, q
returns:
q a double precision 4vector, the quaternion
representation of the matrix 'r'
Note that multiple styles of quaternions are in use.
This routine returns a quaternion that conforms to
the SPICE convention. See the Particulars section
for details.
Any numerical results shown for this example may differ between
platforms as the results depend on the SPICE kernels used as input
and the machine specific arithmetic implementation.
;;
;; Create a rotation matrix of 90 degrees about the Z axis.
;;
cspice_rotate, cspice_halfpi(), 3, r
print,r
IDL outputs:
6.1232340e17 1.0000000 0.0000000
1.0000000 6.1232340e17 0.0000000
0.0000000 0.0000000 1.0000000
;;
;; Convert the matrix to a quaternion.
;;
cspice_m2q, r, q
print, q
IDL outputs: 0.70710678 0.0000000 0.0000000 0.70710678
;;
;; Confirm  q  = 1.
;;
print, q ## transpose(q)
IDL outputs: 1.0000000
Please note, the call sequence:
cspice_m2q, r, q
cspice_q2m, q,r
preserves 'r' except for roundoff error. Yet, the call sequence:
cspice_q2m, q,r
cspice_m2q, r, q
may preserve 'q' or return 'q'.
About SPICE quaternions
=======================
There are (at least) two popular "styles" of quaternions; these
differ in the layout of the quaternion elements, the definition
of the multiplication operation, and the mapping between the set
of unit quaternions and corresponding rotation matrices.
SPICEstyle quaternions have the scalar part in the first
component and the vector part in the subsequent components. The
SPICE convention, along with the multiplication rules for SPICE
quaternions, are those used by William Rowan Hamilton, the
inventor of quaternions.
Another common quaternion style places the scalar component
last. This style is often used in engineering applications.
ICY.REQ
ROTATION.REQ
Icy Version 1.0.1, 06NOV2005, EDW (JPL)
Updated Particulars section to include the
"About SPICE Quaternions" description. Recast
the I/O section to meet Icy format standards.
Icy Version 1.0.0, 16JUN2003, EDW (JPL)
matrix to quaternion
