1 /* zzgfpaq.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 ZZGFPAQ ( Private --- GF, phase angle between bodies ) */
zzgfpaq_(doublereal * et,integer * targ,integer * illmn,integer * obs,char * abcorr,doublereal * value,ftnlen abcorr_len)9 /* Subroutine */ int zzgfpaq_(doublereal *et, integer *targ, integer *illmn,
10 	integer *obs, char *abcorr, doublereal *value, ftnlen abcorr_len)
11 {
12     /* System generated locals */
13     doublereal d__1;
14 
15     /* Builtin functions */
16     /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
17 
18     /* Local variables */
19     extern doublereal vsep_(doublereal *, doublereal *);
20     extern /* Subroutine */ int chkin_(char *, ftnlen);
21     extern logical eqstr_(char *, char *, ftnlen, ftnlen), failed_(void);
22     extern doublereal pi_(void);
23     doublereal lt;
24     extern /* Subroutine */ int chkout_(char *, ftnlen), spkezp_(integer *,
25 	    doublereal *, char *, char *, integer *, doublereal *, doublereal
26 	    *, ftnlen, ftnlen);
27     extern logical return_(void);
28     doublereal pv1[3], pv2[3];
29     char ref[5];
30     doublereal sep;
31 
32 /* $ Abstract */
33 
34 /*     SPICE Private routine intended solely for the support of SPICE */
35 /*     routines.  Users should not call this routine directly due */
36 /*     to the volatile nature of this routine. */
37 
38 /*     Compute the apparent phase angle for a target, observer, */
39 /*     illuminator set of ephemeris objects. */
40 
41 /* $ Disclaimer */
42 
43 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
44 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
45 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
46 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
47 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
48 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
49 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
50 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
51 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
52 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
53 
54 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
55 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
56 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
57 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
58 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
59 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
60 
61 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
62 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
63 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
64 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
65 
66 /* $ Required_Reading */
67 
68 /*     None. */
69 
70 /* $ Keywords */
71 
72 /*     PHASE ANGLE */
73 /*     EPHEMERIS */
74 /*     GEOMETRY */
75 /*     SEARCH */
76 
77 /* $ Declarations */
78 /* $ Brief_I/O */
79 
80 /*     VARIABLE  I/O  DESCRIPTION */
81 /*     --------  ---  -------------------------------------------------- */
82 /*     ET         I   Ephemeris seconds past J2000 TDB. */
83 /*     TARG       I   Target body ID. */
84 /*     ILLMN      I   Illuminating body ID. */
85 /*     OBS        I   Observer body ID. */
86 /*     ABCORR     I   Aberration correction flag. */
87 /*     VALUE      O   Value of phase angle. */
88 
89 /* $ Detailed_Input */
90 
91 /*     ET       the time in ephemeris seconds past J2000 TDB at which */
92 /*              to compute the phase angle. */
93 
94 /*     TARG     the SPICE integer ID for the target body. */
95 
96 /*     ILLMN    the SPICE integer ID for the illuminating body. */
97 
98 /*     OBS      the SPICE integer ID for the observer. */
99 
100 /*     ABCORR   the string description of the aberration corrections to */
101 /*              apply to the state evaluations to account for one-way */
102 /*              light time and stellar aberration. */
103 
104 /*              Any aberration correction accepted by the SPICE */
105 /*              routine SPKEZR is accepted here. See the header */
106 /*              of SPKEZR for a detailed description of the */
107 /*              aberration correction options. For convenience, */
108 /*              the options are listed below: */
109 
110 /*                 'NONE'     Apply no correction. Returns the "true" */
111 /*                            geometric state. */
112 
113 /*                 'LT'       "Reception" case:  correct for */
114 /*                            one-way light time using a Newtonian */
115 /*                            formulation. */
116 
117 /*                 'LT+S'     "Reception" case:  correct for */
118 /*                            one-way light time and stellar */
119 /*                            aberration using a Newtonian */
120 /*                            formulation. */
121 
122 /*                 'CN'       "Reception" case:  converged */
123 /*                            Newtonian light time correction. */
124 
125 /*                 'CN+S'     "Reception" case:  converged */
126 /*                            Newtonian light time and stellar */
127 /*                            aberration corrections. */
128 
129 /*              The ABCORR string lacks sensitivity to case, leading */
130 /*              and trailing blanks. */
131 
132 /* $ Detailed_Output */
133 
134 /*     VALUE      is the optionally light-time corrected phase angle */
135 /*                between TARG and ILLMN as observed from OBS. */
136 
137 /* $ Parameters */
138 
139 /*     None. */
140 
141 /* $ Exceptions */
142 
143 /*     None. */
144 
145 /* $ Files */
146 
147 /*     None. */
148 
149 /* $ Particulars */
150 
151 /*     This routine calculates the phase angle using the location of the */
152 /*     bodies (if point objects) or the center of the bodies (if finite */
153 /*     bodies). */
154 
155 /* $ Examples */
156 
157 /*     None. */
158 
159 /* $ Restrictions */
160 
161 /*     None. */
162 
163 /* $ Literature_References */
164 
165 /*     None. */
166 
167 /* $ Author_and_Institution */
168 
169 /*     E.D. Wright    (JPL) */
170 
171 /* $ Version */
172 
173 /* -    SPICELIB version 1.0.0 23-JUN-2010 (EDW) */
174 
175 /* -& */
176 /* $ Index_Entries */
177 
178 /*   compute the phase of two objects wrt an illumination source */
179 
180 /* -& */
181 
182 /*     SPICELIB functions. */
183 
184 
185 /*     Local Variables. */
186 
187 
188 /*     Standard SPICE error handling. */
189 
190     if (return_()) {
191 	return 0;
192     }
193     chkin_("ZZGFPAQ", (ftnlen)7);
194 
195 /*     This calculation is invariant with respect to reference frame. */
196 /*     Use J2000 for convenience. */
197 
198     s_copy(ref, "J2000", (ftnlen)5, (ftnlen)5);
199 
200 /*     Get the position of the TARG object relative to OBS at ET. */
201 
202     spkezp_(targ, et, ref, abcorr, obs, pv1, &lt, (ftnlen)5, abcorr_len);
203     if (failed_()) {
204 	chkout_("ZZGFPAQ", (ftnlen)7);
205 	return 0;
206     }
207 
208 /*     Get the state of the ILLMN object relative to TARG at ET */
209 /*     for no aberration correction, or ET - LT otherwise. */
210 
211     if (eqstr_(abcorr, "NONE", abcorr_len, (ftnlen)4)) {
212 	spkezp_(illmn, et, ref, abcorr, targ, pv2, &lt, (ftnlen)5, abcorr_len)
213 		;
214     } else {
215 	d__1 = *et - lt;
216 	spkezp_(illmn, &d__1, ref, abcorr, targ, pv2, &lt, (ftnlen)5,
217 		abcorr_len);
218     }
219     if (failed_()) {
220 	chkout_("ZZGFPAQ", (ftnlen)7);
221 	return 0;
222     }
223 
224 /*                       ILLMN      OBS */
225 /*       ILLMN as seen      ^       / */
226 /*       from TARG at       |      / */
227 /*       ET - LT.           |     / */
228 /*                         >|..../< phase angle */
229 /*                          |   / */
230 /*                        . |  / */
231 /*                      .   | / */
232 /*                     .     v     TARG as seen from OBS */
233 /*               SEP   .   TARG    at ET */
234 /*                      .  / */
235 /*                        / */
236 /*                       v */
237 
238 /*        PI = SEP + PHASE */
239 
240 /*        so */
241 
242 /*        PHASE = PI - SEP */
243 
244 /*     Calculate the angle separating the vectors relative to TARG */
245 
246     sep = vsep_(pv1, pv2);
247 
248 /*     The angle of interest is that between -PV1 and PV2 measured from */
249 /*     TARG. Subtract SEP from PI to calculate this angle. */
250 
251     *value = pi_() - sep;
252 
253 /*     All done. */
254 
255     chkout_("ZZGFPAQ", (ftnlen)7);
256     return 0;
257 } /* zzgfpaq_ */
258 
259