Index Page vrelg_c
A B C D E F G H I J K L M N O P Q R S T U V W X
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
       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.
#### 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
        vrelg_c       is the relative difference between v1 and v2.
                      It is defined as:
                                                  || v1 - v2 ||
                                vrelg_c  =   ----------------------
                                           max ( ||v1||, ||v2|| )

                      where || x || indicates the euclidean norm of
                      the vector x ( ||x|| = sqrt( x . 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.

       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
       J.M. Lynch     (JPL)
       E.D. Wright    (JPL)
#### Version
       -CSPICE Version 1.1.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, 6-JUL-1999
#### Index_Entries
       relative difference of n-dimensional vectors
#### Link to routine vrelg_c source file vrelg_c.c

    Wed Jun  9 13:05:32 2010