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
vrelg_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

   vrelg_c ( Vector relative difference, general dimension ) 

   SpiceDouble vrelg_c ( ConstSpiceDouble * v1,
                         ConstSpiceDouble * v2,
                         SpiceInt           ndim  )

Abstract

   Return the relative difference between two vectors of general
   dimension.

Required_Reading

   None.

Keywords

   MATH
   VECTOR


Brief_I/O

   VARIABLE  I/O  DESCRIPTION
   --------  ---  --------------------------------------------------
   v1,
   v2         I   Input vectors.
   ndim       I   Dimension of `v1' and `v2'.

   The function returns the relative difference between two vectors
   of general dimension.

Detailed_Input

   v1,
   v2          are two vectors for which the relative difference is to
               be computed.

   ndim        is the dimension of `v1' and `v2'.

Detailed_Output

   The function returns the relative difference between the two input
   n-dimensional vectors `v1' and `v2'.

   It is defined as:

                        || v1 - v2 ||
      vrelg_c   =   -------------------------
                     maxd ( ||v1||, ||v2|| )

   where ||x|| indicates the Euclidean norm of the vector `x'.

   vrelg_c assumes values in the range [0,2]. If both `v1' and `v2' are
   zero vectors then vrelg_c is defined to be zero.

Parameters

   None.

Exceptions

   Error free.

   1)  If both `v1' and `v2' are zero vectors, then vrelg_c is defined to
       be zero.

Files

   None.

Particulars

   This function computes the relative difference between two vectors
   of general dimension as defined above.

   The function vrel_c may be used to find the relative difference
   for two 3-dimensional vectors.

Examples

   This example determines if the state of Jupiter, with respect
   to Voyager 2, for a set of times is the same for two different
   ephemeris files. Instead of insisting on absolute equality
   between the state vectors, the program will check if the relative
   difference between the vectors is greater than a fixed tolerance.

         #include "SpiceUsr.h"
               .
               .
               .
         /.
         The NAIF code for Jupiter is 599 and for Voyager 2 is -32.
         Set the tolerance to be 0.0005.
         ./

         #define            NUM   500
         #define            JUP   599
         #define            VG2   -32
         #define            TOL   .0005

         /.
         Local variables
         ./
         SpiceDouble        state1 [6][NUM];
         SpiceDouble        state2 [6][NUM];
         SpiceDouble        et     [NUM];
         SpiceDouble        lt;
         SpiceDouble        diff;

         SpiceInt           i;

         .
         .
         .

         /.
         Load  the first SPK file.
         ./
         furnsh_c ( "VG2_SOURCE_1.BSP" );


         /.
         Find the states for each time in the array ET.
         This example assumes that the SPK file can
         provide states for all of the times in the array.
         ./
         for ( i = 0; i < NUM; i++ )
            {
            spkez_c ( JUP, et[i], "J2000", "lt", VG2,
                                   state1[1][i], &lt  );
            }


         /.
         Unload the first file and load the second one.
         ./
         unload_c ( "VG2_SOURCE_1.BSP" );

         furnsh_c ( "VG2_SOURCE_2.BSP" );


         /.
         Find the states from the new file.
         ./
         for ( i = 0; i < NUM; i++ )
            {
            spkez_c ( JUP, et[i], "J2000", "lt",
                      VG2, state2[1][i], &lt  );
            }


         /.
         Now compare the two state vectors for each time.
         ./
         for ( i = 0; i < NUM; i++ )
            {
            diff = vrelg_c ( state1[1][i], state2[1][i], 6 );

            if ( diff > TOL )
               {
                 ...
               }

Restrictions

   None.

Literature_References

   None.

Author_and_Institution

   N.J. Bachman        (JPL)
   J. Diaz del Rio     (ODC Space)
   J.M. Lynch          (JPL)
   E.D. Wright         (JPL)

Version

   -CSPICE Version 1.0.1, 09-AUG-2021 (JDR)

       Edited the header to comply with NAIF standard.

   -CSPICE Version 1.0.0, 28-AUG-2001 (NJB)

       Include interface macro definition file SpiceZim.h.
       Made some minor updates and corrections in the code example.

   -CSPICE Version 1.0.0, 06-JUL-1999 (EDW) (JML)

Index_Entries

   relative difference of n-dimensional vectors
Fri Dec 31 18:41:15 2021