1 /* zzilusta.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 /* Table of constant values */
9 
10 static logical c_false = FALSE_;
11 static integer c__36 = 36;
12 static integer c__3 = 3;
13 static integer c__6 = 6;
14 
15 /* $Procedure ZZILUSTA ( Illumination angle states ) */
zzilusta_(char * method,char * target,char * illum,doublereal * et,char * fixref,char * abcorr,char * obsrvr,doublereal * spoint,doublereal * normal,doublereal * phssta,doublereal * incsta,doublereal * emista,ftnlen method_len,ftnlen target_len,ftnlen illum_len,ftnlen fixref_len,ftnlen abcorr_len,ftnlen obsrvr_len)16 /* Subroutine */ int zzilusta_(char *method, char *target, char *illum,
17 	doublereal *et, char *fixref, char *abcorr, char *obsrvr, doublereal *
18 	spoint, doublereal *normal, doublereal *phssta, doublereal *incsta,
19 	doublereal *emista, ftnlen method_len, ftnlen target_len, ftnlen
20 	illum_len, ftnlen fixref_len, ftnlen abcorr_len, ftnlen obsrvr_len)
21 {
22     /* System generated locals */
23     doublereal d__1;
24 
25     /* Local variables */
26     doublereal uvec[3];
27     extern /* Subroutine */ int vhat_(doublereal *, doublereal *);
28     extern doublereal vdot_(doublereal *, doublereal *), vsep_(doublereal *,
29 	    doublereal *);
30     logical xmit;
31     extern /* Subroutine */ int mxvg_(doublereal *, doublereal *, integer *,
32 	    integer *, doublereal *), zzcorepc_(char *, doublereal *,
33 	    doublereal *, doublereal *, ftnlen), zzvalcor_(char *, logical *,
34 	    ftnlen), zzcorsxf_(logical *, doublereal *, doublereal *,
35 	    doublereal *), chkin_(char *, ftnlen), errch_(char *, char *,
36 	    ftnlen, ftnlen), moved_(doublereal *, integer *, doublereal *);
37     doublereal starg[6];
38     extern doublereal dvsep_(doublereal *, doublereal *);
39     doublereal ltsrc, xform[36]	/* was [6][6] */;
40     logical uselt;
41     extern logical eqstr_(char *, char *, ftnlen, ftnlen), vzero_(doublereal *
42 	    ), failed_(void);
43     extern /* Subroutine */ int cleard_(integer *, doublereal *);
44     doublereal lt;
45     extern doublereal clight_(void);
46     logical attblk[6];
47     doublereal obssta[6];
48     extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
49 	    ftnlen);
50     doublereal srcsta[6];
51     extern /* Subroutine */ int spkcpo_(char *, doublereal *, char *, char *,
52 	    char *, doublereal *, char *, char *, doublereal *, doublereal *,
53 	    ftnlen, ftnlen, ftnlen, ftnlen, ftnlen, ftnlen), vsclip_(
54 	    doublereal *, doublereal *);
55     doublereal fxnsta[6], nrmsta[6];
56     extern /* Subroutine */ int setmsg_(char *, ftnlen), spkcpt_(doublereal *,
57 	     char *, char *, doublereal *, char *, char *, char *, char *,
58 	    doublereal *, doublereal *, ftnlen, ftnlen, ftnlen, ftnlen,
59 	    ftnlen, ftnlen);
60     doublereal etsurf;
61     extern /* Subroutine */ int vminug_(doublereal *, integer *, doublereal *)
62 	    ;
63     doublereal tmpxfm[36]	/* was [6][6] */;
64     extern logical return_(void);
65     extern /* Subroutine */ int sxform_(char *, char *, doublereal *,
66 	    doublereal *, ftnlen, ftnlen);
67     doublereal dlt;
68 
69 /* $ Abstract */
70 
71 /*     SPICE Private routine intended solely for the support of SPICE */
72 /*     routines. Users should not call this routine directly due */
73 /*     to the volatile nature of this routine. */
74 
75 /*     Compute illumination angles and their rates of change at a */
76 /*     surface point. */
77 
78 /* $ Disclaimer */
79 
80 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
81 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
82 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
83 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
84 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
85 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
86 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
87 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
88 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
89 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
90 
91 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
92 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
93 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
94 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
95 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
96 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
97 
98 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
99 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
100 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
101 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
102 
103 /* $ Required_Reading */
104 
105 /*     GF */
106 /*     PCK */
107 /*     TIME */
108 /*     SPK */
109 
110 /* $ Keywords */
111 
112 /*     ANGLE */
113 /*     GEOMETRY */
114 /*     SEARCH */
115 /*     UTILITY */
116 
117 /* $ Declarations */
118 /* $ Abstract */
119 
120 /*     Include file zzabcorr.inc */
121 
122 /*     SPICE private file intended solely for the support of SPICE */
123 /*     routines.  Users should not include this file directly due */
124 /*     to the volatile nature of this file */
125 
126 /*     The parameters below define the structure of an aberration */
127 /*     correction attribute block. */
128 
129 /* $ Disclaimer */
130 
131 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
132 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
133 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
134 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
135 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
136 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
137 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
138 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
139 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
140 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
141 
142 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
143 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
144 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
145 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
146 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
147 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
148 
149 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
150 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
151 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
152 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
153 
154 /* $ Parameters */
155 
156 /*     An aberration correction attribute block is an array of logical */
157 /*     flags indicating the attributes of the aberration correction */
158 /*     specified by an aberration correction string.  The attributes */
159 /*     are: */
160 
161 /*        - Is the correction "geometric"? */
162 
163 /*        - Is light time correction indicated? */
164 
165 /*        - Is stellar aberration correction indicated? */
166 
167 /*        - Is the light time correction of the "converged */
168 /*          Newtonian" variety? */
169 
170 /*        - Is the correction for the transmission case? */
171 
172 /*        - Is the correction relativistic? */
173 
174 /*    The parameters defining the structure of the block are as */
175 /*    follows: */
176 
177 /*       NABCOR    Number of aberration correction choices. */
178 
179 /*       ABATSZ    Number of elements in the aberration correction */
180 /*                 block. */
181 
182 /*       GEOIDX    Index in block of geometric correction flag. */
183 
184 /*       LTIDX     Index of light time flag. */
185 
186 /*       STLIDX    Index of stellar aberration flag. */
187 
188 /*       CNVIDX    Index of converged Newtonian flag. */
189 
190 /*       XMTIDX    Index of transmission flag. */
191 
192 /*       RELIDX    Index of relativistic flag. */
193 
194 /*    The following parameter is not required to define the block */
195 /*    structure, but it is convenient to include it here: */
196 
197 /*       CORLEN    The maximum string length required by any aberration */
198 /*                 correction string */
199 
200 /* $ Author_and_Institution */
201 
202 /*     N.J. Bachman    (JPL) */
203 
204 /* $ Literature_References */
205 
206 /*     None. */
207 
208 /* $ Version */
209 
210 /* -    SPICELIB Version 1.0.0, 18-DEC-2004 (NJB) */
211 
212 /* -& */
213 /*     Number of aberration correction choices: */
214 
215 
216 /*     Aberration correction attribute block size */
217 /*     (number of aberration correction attributes): */
218 
219 
220 /*     Indices of attributes within an aberration correction */
221 /*     attribute block: */
222 
223 
224 /*     Maximum length of an aberration correction string: */
225 
226 
227 /*     End of include file zzabcorr.inc */
228 
229 /* $ Brief_I/O */
230 
231 /*     Variable  I/O  Description */
232 /*     --------  ---  -------------------------------------------------- */
233 /*     METHOD     I   Computation method. */
234 /*     TARGET     I   Name of target body associated with surface point. */
235 /*     ILLUM      I   Name of illumination source. */
236 /*     ET         I   Observation epoch (TDB). */
237 /*     FIXREF     I   Body-fixed reference frame. */
238 /*     ABCORR     I   Aberration correction. */
239 /*     OBSRVR     I   Name of observer. */
240 /*     SPOINT     I   Surface point. */
241 /*     NORMAL     I   Outward normal vector at surface point. */
242 /*     PHSSTA     O   Phase angle state. */
243 /*     INCSTA     O   Solar incidence angle state. */
244 /*     EMISTA     O   Emission angle state. */
245 
246 /* $ Detailed_Input */
247 
248 /*     METHOD         is a string specifying the computation method to */
249 /*                    be used by this routine. The only value currently */
250 /*                    allowed is 'ELLIPSOID'. This indicates that the */
251 /*                    target body shape is modeled as an ellipsoid. */
252 
253 /*                    Case and leading and trailing blanks are not */
254 /*                    significant in METHOD. */
255 
256 /*     TARGET         is the name of the target body associated with the */
257 /*                    surface point SPOINT. TARGET may be a body name or */
258 /*                    an ID code provided as as string. */
259 
260 /*     ILLUM          is the name of the illumination source used to */
261 /*                    define the illumination angles computed by this */
262 /*                    routine. ILLUM may be a body name or an ID code */
263 /*                    provided as as string. */
264 
265 /*     ET             is the observation time. ET is expressed as */
266 /*                    seconds past J2000 TDB. */
267 
268 /*     FIXREF         is the name of the body-centered, body-fixed */
269 /*                    reference frame relative to which SPOINT is */
270 /*                    specified. The frame's center must coincide with */
271 /*                    TARGET. */
272 
273 /*     ABCORR         indicates the aberration corrections to be */
274 /*                    applied. Only reception corrections are supported. */
275 /*                    See the header of ILUMIN for a discussion of */
276 /*                    aberration corrections used in illumination angle */
277 /*                    computations. */
278 
279 /*     OBSRVR         is the name of the observing body. OBSRVR may be a */
280 /*                    body name or an ID code provided as as string. */
281 
282 /*     SPOINT         is a 3-vector containing the cartesian coordinates */
283 /*                    of the surface point at which the illumination */
284 /*                    angle states are to be computed. SPOINT is */
285 /*                    expressed in the body-centered, body-fixed frame */
286 /*                    designated by FIXREF (see description above). */
287 
288 /*                    Units are km. */
289 
290 /*     NORMAL         is an outward normal vector to be used for */
291 /*                    emission angle and solar incidence angle */
292 /*                    calculations. NORMAL should be orthogonal to the */
293 /*                    plane tangent at SPOINT to the target body's */
294 /*                    surface. */
295 
296 /* $ Detailed_Output */
297 
298 /*     PHSSTA         is the phase angle and its rate of change with */
299 /*                    respect to TDB, evaluated at ET. */
300 
301 /*     INCSTA         is the solar incidence angle and its rate of */
302 /*                    change with respect to TDB, evaluated at ET. */
303 
304 /*     EMISTA         is the emission angle and its rate of change with */
305 /*                    respect to TDB, evaluated at ET. */
306 
307 /* $ Parameters */
308 
309 /*     None. */
310 
311 /* $ Exceptions */
312 
313 /*     1)  If the computation method is not recognized, the error */
314 /*         SPICE(INVALIDMETHOD) is signaled. */
315 
316 /*     2)  If ABCORR specifies a transmission aberration correction, */
317 /*         the error SPICE(INVALIDOPTION) is signaled. */
318 
319 /*     3)  If an error occurs while looking up a state vector, the */
320 /*         error will be signaled by a routine in the call tree of */
321 /*         this routine. */
322 
323 /*     4)  If the input normal vector is zero, the error */
324 /*         SPICE(ZEROVECTOR) is signaled. */
325 
326 /* $ Files */
327 
328 /*     See GFILUM. */
329 
330 /* $ Particulars */
331 
332 /*     The term "state" used in the name of this routine refers to */
333 /*     the combination of a function and its derivative with respect */
334 /*     to time. */
335 
336 /*     This routine centralizes computation of illumination angles and */
337 /*     their rates of change. It also exposes the illumination angle */
338 /*     rates of change used by the GF system in order to allow these */
339 /*     rates to be tested using the TSPICE system. */
340 
341 /*     See the SPICELIB routine ILUMIN for a description of the */
342 /*     illumination angles computed by this routine. */
343 
344 /* $ Examples */
345 
346 /*     See usage in ZZGFILDC. */
347 
348 /* $ Restrictions */
349 
350 /*     1) This routine is intended for use only by the GF subsystem. */
351 
352 /* $ Literature_References */
353 
354 /*     None. */
355 
356 /* $ Author_and_Institution */
357 
358 /*     N.J. Bachman    (JPL) */
359 
360 /* $ Version */
361 
362 /* -    SPICELIB Version 1.0.0, 02-APR-2012 (NJB) */
363 
364 /*       Previous version was dated 21-MAR-2012 */
365 
366 /* -& */
367 
368 /*     SPICELIB functions */
369 
370 
371 /*     Local parameters */
372 
373 
374 /*     Local variables */
375 
376     if (return_()) {
377 	return 0;
378     }
379     chkin_("ZZILUSTA", (ftnlen)8);
380 
381 /*     For now, only ellipsoids are supported as target shapes. */
382 
383     if (! eqstr_(method, "ELLIPSOID", method_len, (ftnlen)9)) {
384 	setmsg_("The computation method # was not recognized. ", (ftnlen)45);
385 	errch_("#", method, (ftnlen)1, method_len);
386 	sigerr_("SPICE(INVALIDMETHOD)", (ftnlen)20);
387 	chkout_("ZZILUSTA", (ftnlen)8);
388 	return 0;
389     }
390 
391 /*     Reject zero normal vectors. */
392 
393     if (vzero_(normal)) {
394 	setmsg_("The input normal vector must not be zero, but sadly, it was."
395 		, (ftnlen)60);
396 	sigerr_("SPICE(ZEROVECTOR)", (ftnlen)17);
397 	chkout_("ZZILUSTA", (ftnlen)8);
398 	return 0;
399     }
400 
401 /*     Look up the state of the target with respect to the */
402 /*     observer. We'll represent the state in an inertial */
403 /*     reference frame. */
404 
405     spkcpt_(spoint, target, fixref, et, "J2000", "TARGET", abcorr, obsrvr,
406 	    starg, &lt, target_len, fixref_len, (ftnlen)5, (ftnlen)6,
407 	    abcorr_len, obsrvr_len);
408 
409 /*     Compute the epoch associated with the surface point. */
410 
411     zzcorepc_(abcorr, et, &lt, &etsurf, abcorr_len);
412 
413 /*     Now let the surface point be the observer, let the observation */
414 /*     epoch be ETSURF, and find the apparent state of the illumination */
415 /*     source as seen from the surface point. */
416 
417     spkcpo_(illum, &etsurf, "J2000", "OBSERVER", abcorr, spoint, target,
418 	    fixref, srcsta, &ltsrc, illum_len, (ftnlen)5, (ftnlen)8,
419 	    abcorr_len, target_len, fixref_len);
420     if (failed_()) {
421 	chkout_("ZZILUSTA", (ftnlen)8);
422 	return 0;
423     }
424 
425 /*     We will need to transform the state of the normal vector to */
426 /*     the inertial frame. The epoch at which the transformation must be */
427 /*     evaluated is that associated with the surface point. */
428     sxform_(fixref, "J2000", &etsurf, xform, fixref_len, (ftnlen)5);
429 
430 /*     Correct the body-fixed to inertial frame transformation for the */
431 /*     rate of change with respect to ET of observer-surface point light */
432 /*     time, if light time corrections are used. */
433 
434 /*     Start out by parsing ABCORR. */
435 
436     zzvalcor_(abcorr, attblk, abcorr_len);
437     if (failed_()) {
438 	chkout_("ZZILUSTA", (ftnlen)8);
439 	return 0;
440     }
441     uselt = attblk[1];
442     xmit = attblk[4];
443     if (xmit) {
444 	setmsg_("Aberration correction # is for transmission; only reception"
445 		" corrections are supported by this routine.", (ftnlen)102);
446 	errch_("#", abcorr, (ftnlen)1, abcorr_len);
447 	sigerr_("SPICE(INVALIDOPTION)", (ftnlen)20);
448 	chkout_("ZZILUSTA", (ftnlen)8);
449 	return 0;
450     }
451     if (uselt) {
452 
453 /*        Compute the rate of change with respect to ET of the */
454 /*        observer-surface point light time. This rate is the range rate */
455 /*        divided by the speed of light. */
456 
457 	vhat_(starg, uvec);
458 	dlt = vdot_(&starg[3], uvec) / clight_();
459 
460 /*        Correct the state transformation. */
461 
462 	zzcorsxf_(&c_false, &dlt, xform, tmpxfm);
463 	moved_(tmpxfm, &c__36, xform);
464     }
465 
466 /*     Create a body-fixed state vector for the normal vector. */
467 /*     Convert the normal vector to unit length for safety. */
468 
469     vhat_(normal, fxnsta);
470     cleard_(&c__3, &fxnsta[3]);
471 
472 /*     Transform the state of the normal vector to the inertial */
473 /*     frame. */
474 
475     mxvg_(xform, fxnsta, &c__6, &c__6, nrmsta);
476 
477 /*     We also must adjust the state of the illumination source for the */
478 /*     rate of change with respect to ET of the observer-surface point */
479 /*     light time. The velocity portion of the state we've computed is */
480 /*     the derivative with respect to ETSURF (time at the surface point) */
481 /*     of the surface point-illumination source vector. We must convert */
482 /*     this to a derivative with respect to ET. */
483 
484 /*     This code assumes reception corrections. */
485 
486     if (uselt) {
487 
488 /*        ETSURF = ET - LT, so */
489 
490 /*        d(ETSURF) / d(ET) = ( 1 - DLT ) */
491 
492 	d__1 = 1. - dlt;
493 	vsclip_(&d__1, &srcsta[3]);
494     }
495 
496 /*     The surface-point observer state we wish to use is the negative */
497 /*     of the observer-surface point state. */
498 
499     vminug_(starg, &c__6, obssta);
500 
501 /*     Compute the state (value and rate of change ) */
502 /*     of the phase angle. */
503 
504     phssta[0] = vsep_(obssta, srcsta);
505     phssta[1] = dvsep_(obssta, srcsta);
506 
507 /*     Compute the state of the illumination source */
508 /*     incidence angle. */
509 
510     incsta[0] = vsep_(nrmsta, srcsta);
511     incsta[1] = dvsep_(nrmsta, srcsta);
512 
513 /*     Compute the state of the emission angle. */
514 
515     emista[0] = vsep_(nrmsta, obssta);
516     emista[1] = dvsep_(nrmsta, obssta);
517     chkout_("ZZILUSTA", (ftnlen)8);
518     return 0;
519 } /* zzilusta_ */
520 
521