Table of contents
CSPICE_Q2M calculates the 3x3 double precision, rotation matrix
corresponding to a specified unit quaternion.
Given:
q a unit length double precision 4-vector representing a
SPICE-style quaternion.
help, q
DOUBLE = Array[4]
`q' has the property that
|| q || = 1
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.
help, r
DOUBLE = Array[3,3]
None.
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.
1) Define a unit quaternion, confirm that its norm is equal to 1.0
and convert it to a matrix form.
Example code begins here.
PRO q2m_ex1
;;
;; Define a unit quaternion.
;;
q = [ sqrt(2.d)/2.d, 0.d, 0.d, -sqrt(2.d)/2.d]
print, FORMAT='("Quaternion : ",4F13.8)', q
;;
;; Confirm q satisfies || q || = 1. Calculate q * q.
;;
print, FORMAT='("Norm : ", F13.7)', transpose(q) # q
;;
;; Convert the quaternion to a matrix form.
;;
cspice_q2m, q, m
print, 'Matrix form:'
print, m
END
When this program was executed on a Mac/Intel/IDL8.x/64-bit
platform, the output was:
Quaternion : 0.70710678 0.00000000 0.00000000 -0.70710678
Norm : 1.0000000
Matrix form:
0.0000000 1.0000000 0.0000000
-1.0000000 0.0000000 -0.0000000
-0.0000000 0.0000000 1.0000000
Note, the call sequence:
cspice_m2q, r, q
cspice_q2m, q,r
preserves 'r' except for round-off 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.
SPICE-style 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.
1) If `q' is not a unit quaternion, the output matrix `r' is
the rotation matrix that is the result of converting
normalized `q' to a rotation matrix.
2) If `q' is the zero quaternion, the output matrix `r' is
the identity matrix.
3) If the input argument `q' is undefined, an error is signaled
by the IDL error handling system.
4) If the input argument `q' is not of the expected type, or it
does not have the expected dimensions and size, an error is
signaled by the Icy interface.
5) If the output argument `r' is not a named variable, an error
is signaled by the Icy interface.
None.
None.
ICY.REQ
ROTATION.REQ
None.
J. Diaz del Rio (ODC Space)
E.D. Wright (JPL)
-Icy Version 1.0.2, 10-AUG-2021 (JDR)
Edited the header to comply with NAIF standard. Added
example's problem statement and reformatted example's output.
Added -Parameters, -Exceptions, -Files, -Restrictions,
-Literature_References and -Author_and_Institution sections.
Removed reference to the routine's corresponding CSPICE header from
-Abstract section.
Added arguments' type and size information in the -I/O section.
-Icy Version 1.0.1, 06-NOV-2005 (EDW)
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, 16-JUN-2003 (EDW)
quaternion to matrix
|