1 /* zzsegbox.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 ZZSEGBOX (Bounding box for DSK segment volume element) */
zzsegbox_(doublereal * dskdsc,doublereal * boxctr,doublereal * maxr)9 /* Subroutine */ int zzsegbox_(doublereal *dskdsc, doublereal *boxctr,
10 	doublereal *maxr)
11 {
12     /* Builtin functions */
13     integer i_dnnt(doublereal *);
14 
15     /* Local variables */
16     extern /* Subroutine */ int zzrecbox_(doublereal *, doublereal *,
17 	    doublereal *, doublereal *, doublereal *, doublereal *),
18 	    zzlatbox_(doublereal *, doublereal *, doublereal *, doublereal *,
19 	    doublereal *, doublereal *), zzpdtbox_(doublereal *, doublereal *,
20 	     doublereal *, doublereal *, doublereal *, doublereal *,
21 	    doublereal *), chkin_(char *, ftnlen);
22     doublereal l1, l2, l3;
23     extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
24 	    ftnlen), setmsg_(char *, ftnlen), errint_(char *, integer *,
25 	    ftnlen);
26     extern logical return_(void);
27     integer corsys;
28 
29 /* $ Abstract */
30 
31 /*     Create a bounding box for a DSK segment volume element. */
32 /*     The outputs are the box's center and radius. The center */
33 /*     is relative to the segment's frame center. */
34 
35 /* $ Disclaimer */
36 
37 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
38 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
39 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
40 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
41 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
42 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
43 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
44 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
45 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
46 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
47 
48 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
49 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
50 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
51 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
52 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
53 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
54 
55 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
56 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
57 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
58 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
59 
60 /* $ Required_Reading */
61 
62 /*     None. */
63 
64 /* $ Keywords */
65 
66 /*     GEOMETRY */
67 /*     MATH */
68 
69 /* $ Declarations */
70 
71 /*     Include file dskdsc.inc */
72 
73 /*     This include file declares parameters for DSK segment descriptors. */
74 
75 /* -       SPICELIB Version 1.0.0 08-FEB-2017 (NJB) */
76 
77 /*           Updated version info. */
78 
79 /*           22-JAN-2016 (NJB) */
80 
81 /*              Added parameter for data class 2. Changed name of data */
82 /*              class 1 parameter. Corrected data class descriptions. */
83 
84 /*           13-MAY-2010 (NJB) */
85 
86 /*              Descriptor now contains two ID codes, one for the */
87 /*              surface, one for the associated ephemeris object. This */
88 /*              supports association of multiple surfaces with one */
89 /*              ephemeris object without creating file management */
90 /*              issues. */
91 
92 /*              Room was added for coordinate system definition */
93 /*              parameters. */
94 
95 /*               Flag arrays and model ID/component entries were deleted. */
96 
97 /*            11-SEP-2008 (NJB) */
98 
99 
100 /*     DSK segment descriptors are implemented as an array of d.p. */
101 /*     numbers.  Note that each integer descriptor datum occupies one */
102 /*     d.p. value. */
103 
104 
105 
106 
107 /*     Segment descriptor parameters */
108 
109 /*     Each segment descriptor occupies a contiguous */
110 /*     range of DAS d.p. addresses. */
111 
112 /*        The DSK segment descriptor layout is: */
113 
114 /*           +---------------------+ */
115 /*           | Surface ID code     | */
116 /*           +---------------------+ */
117 /*           | Center ID code      | */
118 /*           +---------------------+ */
119 /*           | Data class code     | */
120 /*           +---------------------+ */
121 /*           | Data type           | */
122 /*           +---------------------+ */
123 /*           | Ref frame code      | */
124 /*           +---------------------+ */
125 /*           | Coord sys code      | */
126 /*           +---------------------+ */
127 /*           | Coord sys parameters|  {10 elements} */
128 /*           +---------------------+ */
129 /*           | Min coord 1         | */
130 /*           +---------------------+ */
131 /*           | Max coord 1         | */
132 /*           +---------------------+ */
133 /*           | Min coord 2         | */
134 /*           +---------------------+ */
135 /*           | Max coord 2         | */
136 /*           +---------------------+ */
137 /*           | Min coord 3         | */
138 /*           +---------------------+ */
139 /*           | Max coord 3         | */
140 /*           +---------------------+ */
141 /*           | Start time          | */
142 /*           +---------------------+ */
143 /*           | Stop time           | */
144 /*           +---------------------+ */
145 
146 /*     Parameters defining offsets for segment descriptor elements */
147 /*     follow. */
148 
149 
150 /*     Surface ID code: */
151 
152 
153 /*     Central ephemeris object NAIF ID: */
154 
155 
156 /*     Data class: */
157 
158 /*     The "data class" is a code indicating the category of */
159 /*     data contained in the segment. */
160 
161 
162 /*     Data type: */
163 
164 
165 /*     Frame ID: */
166 
167 
168 /*     Coordinate system code: */
169 
170 
171 /*     Coordinate system parameter start index: */
172 
173 
174 /*     Number of coordinate system parameters: */
175 
176 
177 /*     Ranges for coordinate bounds: */
178 
179 
180 /*     Coverage time bounds: */
181 
182 
183 /*     Descriptor size (24): */
184 
185 
186 /*     Data class values: */
187 
188 /*        Class 1 indicates a surface that can be represented as a */
189 /*                single-valued function of its domain coordinates. */
190 
191 /*                An example is a surface defined by a function that */
192 /*                maps each planetodetic longitude and latitude pair to */
193 /*                a unique altitude. */
194 
195 
196 /*        Class 2 indicates a general surface. Surfaces that */
197 /*                have multiple points for a given pair of domain */
198 /*                coordinates---for example, multiple radii for a given */
199 /*                latitude and longitude---belong to class 2. */
200 
201 
202 
203 /*     Coordinate system values: */
204 
205 /*        The coordinate system code indicates the system to which the */
206 /*        tangential coordinate bounds belong. */
207 
208 /*        Code 1 refers to the planetocentric latitudinal system. */
209 
210 /*        In this system, the first tangential coordinate is longitude */
211 /*        and the second tangential coordinate is latitude. The third */
212 /*        coordinate is radius. */
213 
214 
215 
216 /*        Code 2 refers to the cylindrical system. */
217 
218 /*        In this system, the first tangential coordinate is radius and */
219 /*        the second tangential coordinate is longitude. The third, */
220 /*        orthogonal coordinate is Z. */
221 
222 
223 
224 /*        Code 3 refers to the rectangular system. */
225 
226 /*        In this system, the first tangential coordinate is X and */
227 /*        the second tangential coordinate is Y. The third, */
228 /*        orthogonal coordinate is Z. */
229 
230 
231 
232 /*        Code 4 refers to the planetodetic/geodetic system. */
233 
234 /*        In this system, the first tangential coordinate is longitude */
235 /*        and the second tangential coordinate is planetodetic */
236 /*        latitude. The third, orthogonal coordinate is altitude. */
237 
238 
239 
240 /*     End of include file dskdsc.inc */
241 
242 /* $ Brief_I/O */
243 
244 /*     Variable  I/O  Description */
245 /*     --------  ---  -------------------------------------------------- */
246 /*     DSKDSC     I   DSK segment descriptor. */
247 /*     CENTER     O   Center of bounding box. */
248 /*     RADIUS     O   Radius of box. */
249 
250 /* $ Detailed_Input */
251 
252 /*     DSKDSC     is the DSK descriptor for the segment of interest. */
253 
254 /* $ Detailed_Output */
255 
256 /*     CENTER     is a double precision 3-vector representing the center */
257 /*                of a box tangent to and containing the volume */
258 /*                specified by the coordinate system, coordinate */
259 /*                parameters, if any, and bounds specified in the DSK */
260 /*                segment descriptor. */
261 
262 /*                The box bounds the surface specified by the input */
263 /*                descriptor; the offset between the center of the */
264 /*                segment's reference frame and the segment's central */
265 /*                body plays no role. */
266 
267 /*     RADIUS     is the radius of the sphere that circumscribes the */
268 /*                box. RADIUS is equal to the length of a line segment */
269 /*                connecting the center of the box to any corner. */
270 
271 /* $ Parameters */
272 
273 /*     None. */
274 
275 /* $ Exceptions */
276 
277 /*     1)  If coordinate system specified in the descriptor is not */
278 /*         recognized, the error SPICE(NOTSUPPORTED) is signaled. */
279 
280 /*     2)  Any errors that occur while deriving the bounding box */
281 /*         will be signaled by routines in the call tree of this */
282 /*         routine. */
283 
284 /* $ Files */
285 
286 /*     None. */
287 
288 /* $ Particulars */
289 
290 /*     This routine consolidates the logic branch needed to compute a */
291 /*     bounding box for a DSK segment. Using this routine can eliminate */
292 /*     the need to test higher-level routines using each type of */
293 /*     coordinate system. */
294 
295 /*     The box bounds the surface specified by the input descriptor; the */
296 /*     offset between the center of the segment's reference frame and */
297 /*     the segment's central body plays no role. */
298 
299 /*     To compute a body's DSK bounding sphere, centered at the body, */
300 /*     and taking into account all loaded segments, use ZZDSKSPH. */
301 
302 /* $ Examples */
303 
304 /*     None. */
305 
306 /* $ Restrictions */
307 
308 /*     None. */
309 
310 /* $ Literature_References */
311 
312 /*     None. */
313 
314 /* $ Author_and_Institution */
315 
316 /*     N.J. Bachman   (JPL) */
317 
318 /* $ Version */
319 
320 /* -    SPICELIB Version 1.0.0, 17-JUN-2016 (NJB) */
321 
322 /* -& */
323 /* $ Index_Entries */
324 
325 /*     bounding box for dsk segment volume element */
326 
327 /* -& */
328 
329 /*     SPICELIB functions */
330 
331 
332 /*     Local variables */
333 
334     if (return_()) {
335 	return 0;
336     }
337     chkin_("ZZSEGBOX", (ftnlen)8);
338     corsys = i_dnnt(&dskdsc[5]);
339     if (corsys == 1) {
340 	zzlatbox_(&dskdsc[16], boxctr, &l1, &l2, &l3, maxr);
341     } else if (corsys == 3) {
342 	zzrecbox_(&dskdsc[16], boxctr, &l1, &l2, &l3, maxr);
343     } else if (corsys == 4) {
344 	zzpdtbox_(&dskdsc[16], &dskdsc[6], boxctr, &l1, &l2, &l3, maxr);
345     } else {
346 	setmsg_("Coordinate system # is not supported.", (ftnlen)37);
347 	errint_("#", &corsys, (ftnlen)1);
348 	sigerr_("SPICE(NOTSUPPORTED)", (ftnlen)19);
349 	chkout_("ZZSEGBOX", (ftnlen)8);
350 	return 0;
351     }
352     chkout_("ZZSEGBOX", (ftnlen)8);
353     return 0;
354 } /* zzsegbox_ */
355 
356