Index of Functions: A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X 
Index Page
cspice_qxq

Table of contents
Abstract
I/O
Parameters
Examples
Particulars
Exceptions
Files
Restrictions
Required_Reading
Literature_References
Author_and_Institution
Version
Index_Entries


Abstract


   CSPICE_QXQ returns the product of two quaternions.

I/O


   Given:

      q1   is a double precision 4-vector representing a SPICE-style
               quaternion.

               help, q1
                  DOUBLE = Array[4]

           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.

      q2   is a second double precision 4-vector SPICE quaternion.

               help, q2
                  DOUBLE = Array[4]

   the call:

      cspice_qxq, q1, q2, qout

   returns:

      qout   is a double precision 4-vector representing the
             quaternion product

                     q1 * q2

             Representing q(i) as the sums of scalar (real)
             part s(i) and vector (imaginary) part v(i)
             respectively,

                     q1 = s1 + v1
                     q2 = s2 + v2

             'qout' has scalar part s3 defined by

                     s3 = s1 * s2 - <v1, v2>

             and vector part v3 defined by

                     v3 = s1 * v2  +  s2 * v1  +  v1 x v2

            where the notation < , > denotes the inner
            product operator and x indicates the cross
            product operator.

               help, qout
                  DOUBLE = Array[4]

Parameters


   None.

Examples


   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) Given the "basis" quaternions:

         qid:  ( 1.0, 0.0, 0.0, 0.0 )
         qi :  ( 0.0, 1.0, 0.0, 0.0 )
         qj :  ( 0.0, 0.0, 1.0, 0.0 )
         qk :  ( 0.0, 0.0, 0.0, 1.0 )

      the following quaternion products give these results:

          Product       Expected result
         -----------   ----------------------
          qi  * qj     ( 0.0, 0.0, 0.0, 1.0 )
          qj  * qk     ( 0.0, 1.0, 0.0, 0.0 )
          qk  * qi     ( 0.0, 0.0, 1.0, 0.0 )
          qi  * qi     (-1.0, 0.0, 0.0, 0.0 )
          qj  * qj     (-1.0, 0.0, 0.0, 0.0 )
          qk  * qk     (-1.0, 0.0, 0.0, 0.0 )
          qid * qi     ( 0.0, 1.0, 0.0, 0.0 )
          qi  * qid    ( 0.0, 1.0, 0.0, 0.0 )
          qid * qj     ( 0.0, 0.0, 1.0, 0.0 )

      The following code example uses cspice_qxq to produce these results.

      Example code begins here.


      PRO qxq_ex1

         ;;
         ;; Let 'qid', 'qi', 'qj', 'qk' be the "basis"
         ;; quaternions
         ;;
         qid  =  [ 1.d, 0.d, 0.d, 0.d ]
         qi   =  [ 0.d, 1, 0, 0 ]
         qj   =  [ 0.d, 0, 1, 0 ]
         qk   =  [ 0.d, 0, 0, 1 ]

         ;;
         ;; respectively.  Then the calls
         ;;
         cspice_qxq, qi, qj, ixj
         cspice_qxq, qj, qk, jxk
         cspice_qxq, qk, qi, kxi

         ;;
         ;; produce the results
         ;;
         ;; ixj == qk
         ;; jxk == qi
         ;; kxi == qj
         ;;
         print, format='("qi x qj  = ",4F8.2)', ixj
         print, format='("     qk  = ",4F8.2)', qk
         print

         print, format='("qj x qk  = ",4F8.2)', jxk
         print, format='("     qi  = ",4F8.2)', qi
         print

         print, format='("qk x qi  = ",4F8.2)', kxi
         print, format='("     qj  = ",4F8.2)', qj
         print

         ;;
         ;; All of the calls
         ;;
         cspice_qxq, qi, qi, qout1
         cspice_qxq, qj, qj, qout2
         cspice_qxq, qk, qk, qout3

         ;;
         ;; produce the result
         ;;
         ;; qout  ==  -qid
         ;;
         print, format='("qi x qi  = ",4F8.2)', qout1
         print, format='("   -qid  = ",4F8.2)', -qid
         print

         print, format='("qj x qj  = ",4F8.2)', qout2
         print, format='("   -qid  = ",4F8.2)', -qid
         print

         print, format='("qk x qk  = ",4F8.2)', qout3
         print, format='("   -qid  = ",4F8.2)', -qid
         print

         ;;
         ;; For any quaternion Q, the calls
         ;;
         cspice_qxq, qid, qi , qout1
         cspice_qxq, qi,  qid, qout2
         cspice_qxq, qid, qj,  qout3

         ;;
         ;;  produce the result
         ;;
         ;;    qout  ==  q
         ;;
         print, format='("qid x qi = ",4F8.2)', qout1
         print, format='("      qi = ",4F8.2)', qi
         print

         print, format='("qi x qid = ",4F8.2)', qout2
         print, format='("      qi = ",4F8.2)', qi
         print

         print, format='("qid x qj = ",4F8.2)', qout3
         print, format='("      qj = ",4F8.2)', qj

      END


      When this program was executed on a Mac/Intel/IDL8.x/64-bit
      platform, the output was:


      qi x qj  =     0.00    0.00    0.00    1.00
           qk  =     0.00    0.00    0.00    1.00

      qj x qk  =     0.00    1.00    0.00    0.00
           qi  =     0.00    1.00    0.00    0.00

      qk x qi  =     0.00    0.00    1.00    0.00
           qj  =     0.00    0.00    1.00    0.00

      qi x qi  =    -1.00    0.00    0.00    0.00
         -qid  =    -1.00   -0.00   -0.00   -0.00

      qj x qj  =    -1.00    0.00    0.00    0.00
         -qid  =    -1.00   -0.00   -0.00   -0.00

      qk x qk  =    -1.00    0.00    0.00    0.00
         -qid  =    -1.00   -0.00   -0.00   -0.00

      qid x qi =     0.00    1.00    0.00    0.00
            qi =     0.00    1.00    0.00    0.00

      qi x qid =     0.00    1.00    0.00    0.00
            qi =     0.00    1.00    0.00    0.00

      qid x qj =     0.00    0.00    1.00    0.00
            qj =     0.00    0.00    1.00    0.00


Particulars


   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.

Exceptions


   1)  If any of the input arguments, `q1' or `q2', is undefined, an
       error is signaled by the IDL error handling system.

   2)  If any of the input arguments, `q1' or `q2', is not of the
       expected type, or it does not have the expected dimensions and
       size, an error is signaled by the Icy interface.

   3)  If the output argument `qout' is not a named variable, an
       error is signaled by the Icy interface.

Files


   None.

Restrictions


   None.

Required_Reading


   ICY.REQ
   ROTATIONS.REQ

Literature_References


   None.

Author_and_Institution


   J. Diaz del Rio     (ODC Space)
   E.D. Wright         (JPL)

Version


   -Icy Version 1.0.1, 10-AUG-2021 (JDR)

       Edited -Examples section to comply with NAIF standard. Added
       example's problem statement and modified code example to
       produce formatted 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.0, 06-NOV-2005 (EDW)

Index_Entries


   None.



Fri Dec 31 18:43:06 2021