1 /* vdist.f -- translated by f2c (version 19980913).
2 You must link the resulting object file with the libraries:
3 -lf2c -lm (in that order)
4 */
5
6 #include "f2c.h"
7
8 /* $Procedure VDIST ( Vector distance ) */
vdist_(doublereal * v1,doublereal * v2)9 doublereal vdist_(doublereal *v1, doublereal *v2)
10 {
11 /* System generated locals */
12 doublereal ret_val;
13
14 /* Local variables */
15 doublereal diff[3];
16 extern /* Subroutine */ int vsub_(doublereal *, doublereal *, doublereal *
17 );
18 extern doublereal vnorm_(doublereal *);
19
20 /* $ Abstract */
21
22 /* Return the distance between two three-dimensional vectors. */
23
24 /* $ Disclaimer */
25
26 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
27 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
28 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
29 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
30 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
31 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
32 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
33 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
34 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
35 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
36
37 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
38 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
39 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
40 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
41 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
42 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
43
44 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
45 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
46 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
47 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
48
49 /* $ Required_Reading */
50
51 /* None. */
52
53 /* $ Keywords */
54
55 /* VECTOR */
56
57 /* $ Declarations */
58 /* $ Brief_I/O */
59
60 /* Variable I/O Description */
61 /* -------- --- -------------------------------------------------- */
62
63 /* V1, */
64 /* V2 I Two 3-vectors. */
65
66 /* The function returns the distance between V1 and V2. */
67
68 /* $ Detailed_Input */
69
70 /* V1, */
71 /* V2 are two vectors in three-dimensional space, the */
72 /* distance between which is desired. */
73
74 /* $ Detailed_Output */
75
76 /* The function returns the distance between V1 and V2. This is */
77 /* defined as */
78
79 /* || V1 - V2 ||, */
80
81 /* where || x || indicates the Euclidean norm of the vector x. */
82
83 /* $ Parameters */
84
85 /* None. */
86
87 /* $ Exceptions */
88
89 /* Error free. */
90
91 /* $ Files */
92
93 /* None. */
94
95 /* $ Particulars */
96
97 /* This function is simply shorthand for the code */
98
99 /* CALL VSUB ( V1, V2, DIFF ) */
100
101 /* DIST = VNORM ( DIFF ) */
102
103 /* Using this function saves you the annoyance of declaring local */
104 /* storage for the difference vector DIFF. */
105
106
107 /* The Euclidean norm of a three-dimensional vector (x, y, z) is */
108 /* defined as */
109
110 /* 1/2 */
111 /* 2 2 2 */
112 /* ( x + y + z ). */
113
114
115 /* This number is the distance of the point (x, y, z) from the */
116 /* origin. If A and B are two vectors whose components are */
117
118 /* ( A(1), A(2), A(3) ) and ( B(1), B(2), B(3) ), */
119
120 /* then the distance between A and B is the norm of the difference */
121 /* A - B, which has components */
122
123
124 /* ( A(1) - B(1), A(2) - B(2), A(3) - B(3) ). */
125
126
127 /* A related routine is VDISTG, which computes the distance between */
128 /* two vectors of general dimension. */
129
130 /* $ Examples */
131
132 /* 1) If V1 is */
133
134 /* ( 2.0D0, 3.0D0, 0.D0 ) */
135
136 /* and V2 is */
137
138 /* ( 5.0D0, 7.0D0, 12.D0 ), */
139
140 /* VDIST (V1, V2) will be 13.D0. */
141
142
143 /* 2) If VGR2 and NEP are states of the Voyager 2 spacecraft and */
144 /* Neptune with respect to some common center at a given time */
145 /* ET, then */
146
147 /* VDIST ( VGR2, NEP ) */
148
149 /* yields the distance between the spacecraft and Neptune at time */
150 /* ET. */
151
152 /* $ Restrictions */
153
154 /* None. */
155
156 /* $ Literature_References */
157
158 /* None. */
159
160 /* $ Author_and_Institution */
161
162 /* N.J. Bachman (JPL) */
163
164 /* $ Version */
165
166 /* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
167
168 /* Comment section for permuted index source lines was added */
169 /* following the header. */
170
171 /* - SPICELIB Version 1.0.0, 08-JUL-1990 (NJB) */
172
173 /* -& */
174 /* $ Index_Entries */
175
176 /* distance between 3-dimensional vectors */
177
178 /* -& */
179
180 /* SPICELIB functions */
181
182
183 /* Local variables */
184
185
186 /* No surprises. */
187
188 vsub_(v1, v2, diff);
189 ret_val = vnorm_(diff);
190 return ret_val;
191 } /* vdist_ */
192
193