Документ взят из кэша поисковой машины. Адрес
оригинального документа
: http://www.stsci.edu/~sontag/spicedocs/cspice/vrelg_c.html
Дата изменения: Sat Dec 17 06:10:11 2005 Дата индексирования: Sun Apr 10 23:29:00 2016 Кодировка: |
Return the relative difference between two vectors of general dimension.
None.
Variable I/O Description -------- --- -------------------------------------------------- v1,v2 I Input vectors. ndim I Dimension of v1 and v2.
v1, v2 are two vectors for which the relative difference is to be computed. ndim is the dimension of v1 and v2.
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.
None.
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.
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], < ); } /. 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], < ); } /. 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 ) { ... }
None.
Error free. If both v1 and v2 are zero vectors then vrelg_c is defined to be zero.
None.
J.M. Lynch (JPL) E.D. Wright (JPL)
None.
-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
relative difference of n-dimensional vectors