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 vupack_c

Table of contents

Procedure Abstract Required_Reading Keywords Brief_I/O Detailed_Input | Detailed_Output Parameters Exceptions Files Particulars Examples | Restrictions Literature_References Author_and_Institution Version Index_Entries

#### Procedure

       vupack_c ( Unpack three scalar components from a vector )

       void vupack_c ( ConstSpiceDouble     v[3],
                       SpiceDouble        * x,
                       SpiceDouble        * y,
                       SpiceDouble        * z     )

#### Abstract

       Unpack three scalar components from a vector.

#### Required_Reading

       None.

#### Keywords

       VECTOR

#### Brief_I/O

       VARIABLE  I/O  DESCRIPTION
       --------  ---  --------------------------------------------------
       v          I   Input 3-dimensional vector.
       x,
       y,
       z          O   Scalar components of the vector.

#### Detailed_Input

       v           is a double precision 3-dimensional vector.

#### Detailed_Output

       x,
       y,
       z           are the double precision scalar components of the
                   vector `v'. The following equalities hold:

                      v[0] = x
                      v[1] = y
                      v[2] = z

#### Parameters

       None.

#### Exceptions

       Error free.

#### Files

       None.

#### Particulars

       Basically, this is just shorthand notation for the common
       sequence

          x = v[0];
          y = v[1];
          z = v[2];

       The routine is useful largely for two reasons. First, it
       reduces the chance that the programmer will make a "cut and
       paste" mistake, like

          x = v[0];
          y = v[0];
          z = v[0];

       Second, it makes conversions between equivalent units simpler,
       and clearer. For instance, the sequence

          x = v[0] * rpd_c();
          y = v[1] * rpd_c();
          z = v[2] * rpd_c();

       can be replaced by the (nearly) equivalent sequence

          vscl_c   ( rpd_c(),  v,   v  );
          vupack_c ( v,  &x,  &y,  &z  );

#### Examples

       The numerical results shown for this example may differ across
       platforms. The results depend on the SPICE kernels used as
       input, the compiler and supporting libraries, and the machine
       specific arithmetic implementation.

       1) Suppose that you have an instrument kernel that provides,
          within a single keyword, the three frequencies used by the
          instrument, and that you want to use these frequencies
          independently within your code.

          The following code example demonstrates how to use vupack_c
          to get these frequencies into independent scalar variables.

          Use the kernel shown below, an IK defining the three
          frequencies used by an instrument with NAIF ID -999001.

             KPL/IK

             File name: vupack_ex1.ti

             The keyword below define the three frequencies used by a
             hypothetical instrument (NAIF ID -999001). They correspond
             to three filters: red, green and blue. Frequencies are
             given in micrometers.

             \begindata

                INS-999001_FREQ_RGB   = (  0.65,  0.55, 0.475 )
                INS-999001_FREQ_UNITS = ( 'MICROMETERS'       )

             \begintext

             End of IK

          Example code begins here.

          /.
             Program vupack_ex1
          ./
          #include <stdio.h>
          #include "SpiceUsr.h"

          int main( )
          {

             /.
             Local parameters.
             ./
             #define IKNAME       "vupack_ex1.ti"
             #define KEYWRD       "INS-999001_FREQ_RGB"

             /.
             Local variables.
             ./
             SpiceDouble          ddata  [3];
             SpiceDouble          red;
             SpiceDouble          green;
             SpiceDouble          blue;

             SpiceInt             n;

             SpiceBoolean         found;

             /.
             Load the instrument kernel.
             ./
             furnsh_c ( IKNAME );

             /.
             Get the frequency data from the kernel pool.
             ./
             gdpool_c ( KEYWRD, 0, 3, &n, ddata, &found );

             if ( found )
             {
                vupack_c ( ddata, &red, &green, &blue );
                printf( "Blue  (nm):  %5.2f\n", blue  * 1000.0 );
                printf( "Green (nm):  %5.2f\n", green * 1000.0 );
                printf( "Red   (nm):  %5.2f\n", red   * 1000.0 );
             }
             else
             {
                printf( "No data found in the kernel pool for %s\n", KEYWRD );
             }

             return ( 0 );
          }

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

          Blue  (nm):  475.00
          Green (nm):  550.00
          Red   (nm):  650.00

#### Restrictions

       None.

#### Literature_References

       None.

#### Author_and_Institution

       N.J. Bachman        (JPL)
       J. Diaz del Rio     (ODC Space)
       I.M. Underwood      (JPL)

#### Version

       -CSPICE Version 1.0.1, 03-SEP-2020 (JDR)

           Edited the header to comply with NAIF standard. Added complete
           code example.

       -CSPICE Version 1.0.0, 07-NOV-2006 (NJB)

           Corrected header errors that claimed this routine
           performs the function of vpack_c.

       -CSPICE Version 1.0.0, 28-JUN-1999 (IMU) (NJB)

#### Index_Entries

       unpack three scalar components from a vector

#### Link to routine vupack_c source file vupack_c.c

    Fri Dec 31 18:41:15 2021