vdist_c |

Table of contents## Procedurevdist_c ( Vector distance ) SpiceDouble vdist_c ( ConstSpiceDouble v1[3], ConstSpiceDouble v2[3] ) ## AbstractReturn the distance between two three-dimensional vectors. ## Required_ReadingNone. ## KeywordsVECTOR ## Brief_I/OVARIABLE I/O DESCRIPTION -------- --- -------------------------------------------------- v1, v2 I Two 3-vectors. The function returns the distance between v1 and v2. ## Detailed_Inputv1, v2 are two vectors in three-dimensional space, the distance between which is desired. ## Detailed_OutputThe function returns the distance between v1 and v2. This is defined as || v1 - v2 ||, where || x || indicates the Euclidean norm of the vector x. ## ParametersNone. ## ExceptionsError free. ## FilesNone. ## ParticularsThis function is simply shorthand for the code vsub_c ( v1, v2, diff ); dist = vnorm_c ( diff ); Using this function saves you the annoyance of declaring local storage for the difference vector `diff'. The Euclidean norm of a three-dimensional vector (x, y, z) is defined as 1/2 2 2 2 ( x + y + z ). This number is the distance of the point (x, y, z) from the origin. If `a' and `b' are two vectors whose components are ( a[0], a[1], a[2] ) and ( b[0], b[1], b[2] ), then the distance between `a' and `b' is the norm of the difference a - b, which has components ( a[0] - b[0], a[1] - b[1], a[2] - b[2] ). A related routine is vdistg_c, which computes the distance between two vectors of general dimension. ## ExamplesThe numerical results shown for these examples 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) Define two three-dimensional vectors and calculate the distance between them. Example code begins here. /. Program vdist_ex1 ./ #include <stdio.h> #include "SpiceUsr.h" int main( ) { /. Local variables. ./ SpiceDouble dist; /. Define the vectors, and calculate the distance between the coordinates. ./ SpiceDouble v1 [ 3 ] = { 1.0, 0.0, 0.0 }; SpiceDouble v2 [ 3 ] = { 0.0, 1.0, 0.0 }; dist = ## RestrictionsNone. ## Literature_ReferencesNone. ## Author_and_InstitutionN.J. Bachman (JPL) J. Diaz del Rio (ODC Space) E.D. Wright (JPL) ## Version-CSPICE Version 1.2.1, 25-AUG-2021 (JDR) Edited the header to comply with NAIF standard. Added two complete examples to the -Examples section. -CSPICE Version 1.2.0, 22-OCT-1998 (NJB) Made input vectors const. Removed #include of SpiceZfc.h. -CSPICE Version 1.1.0, 06-MAR-1998 (EDW) Removed non printing character. -CSPICE Version 1.0.0, 08-FEB-1998 (EDW) ## Index_Entriesdistance between 3-dimensional vectors |

Fri Dec 31 18:41:14 2021