CSPICE_Q2M calculates the 3x3 double precision, rotation matrix
corresponding to a specified unit quaternion.
For important details concerning this module's function, please refer to
the CSPICE routine q2m_c.
Given:
q is a unit length double precision 4vector representing
a SPICEstyle quaternion.
Note that multiple styles of quaternions are in use.
This routine will not work properly if the input
quaternions do not conform to the SPICE convention.
See the Particulars section for details.
the call:
cspice_q2m, q, r
returns:
r a 3x3 double precision rotation matrix representation of
the quaternion.
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.
;;
;; Define a unit quaternion.
;;
q = [ sqrt(2.d)/2.d, 0.d, 0.d, sqrt(2.d)/2.d]
print, q
IDL outputs: 0.70710678 0.0000000 0.0000000 0.70710678
;;
;; Confirm q satisfies  q  = 1. Calculate q * q.
;;
print, transpose(q) # q
IDL outputs: 1.0000000
;;
;; Convert the quaternion to a matrix form.
;;
cspice_q2m, q, m
print, m
IDL outputs:
0.0000000 1.0000000 0.0000000
1.0000000 0.0000000 0.0000000
0.0000000 0.0000000 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)
quaternion to matrix
