|
|
1.1 root 1: #include "sky.h"
2: #include <stdio.h>
3:
4: main(argc,argv)
5: int argc;
6: char *argv[];
7: {
8:
9: pi = 3.1415926535897932;
10: radian = pi/180.;
11: radsec = radian/3600.;
12: args(argc,argv);
13: init();
14:
15:
16: for(;;){
17: day = readate();
18: printf("Date: ");
19: pdate(day);
20: printf("\n");
21: printf("Time: ");
22: ptime(day);
23: printf("\n");
24: if(day < 0.)
25: printf("Julian date %.4f\n", day+2415020.);
26: setime(day);
27:
28: if(flags&TOPO){
29: printf(" rt. ascens. decl. az. elev. semi.\n");
30: }
31:
32: if((flags&HELIO)==0){
33: lambda = 0.;
34: beta = 0.;
35: rad = 0.;
36: ldot = 0.;
37: rdot = 0.;
38: bdot = 0.;
39: }else{
40: object = "earth ";
41: }
42: helio();
43:
44: /*
45: * Shadow computation for lunar eclipse.
46: */
47:
48: rps = georad;
49: shra = alpha + 180.*radian;
50: shdecl = -delta;
51:
52: geo();
53:
54: /*
55: * Computation for solar eclipse.
56: */
57:
58: sunra = ra;
59: sundec = decl2;
60: sunsd = semi2;
61:
62: output();
63:
64: moon();
65: output();
66:
67: merc();
68: output();
69:
70: venus();
71: output();
72:
73: mars();
74: output();
75:
76: jup();
77: output();
78:
79: sat();
80: output();
81:
82: if((flags&NOSTAR)==0){
83: stars();
84: }
85:
86: }
87:
88: }
89:
90: args(argc,argv)
91: int argc;
92: char *argv[];
93: {
94: register char *p, *q;
95:
96: p = "";
97: if(argc>1)
98: p = argv[1];
99: while(*p)
100: switch(*p++){
101:
102: /*
103: * Meanings of options.
104: *
105: * APPARENT: Catalogue apparent place omits
106: * short period terms of nutation for direct
107: * comparison with "Apparent Places of
108: * Fundamental Stars".
109: *
110: * OCCULT: Changes the semidiameters of the
111: * sun and moon, and moves the moon slightly.
112: *
113: * LATUD: prompts for longitude, latitude and elevation.
114: *
115: * MEAN: omits all nutation, for direct comparison
116: * with star catalogs. Also omits the E-terms of nutation.
117: *
118: * NOSTAR: Solar system only.
119: *
120: * STCATL: Prompts for name of file containing star catalog.
121: *
122: * XYZ: Prints x,y,z, coordinates vice angles.
123: *
124: * GEO: Reports apparent geocentric place.
125: *
126: * HELIO: Reports heliocentric place.
127: *
128: * TOPO: Reports topocentric place.Default location
129: * is the hollyhock in Morris's back yard.
130: *
131: * ECLIPTIC: Reports places in ecliptic vs. equatorial coords.
132: *
133: * KITCH: Input times are interpreted as local time
134: * vs. Greenwich time (but still E.T.)
135: */
136:
137: case 'a':
138: flags |= APPARENT;
139: continue;
140:
141: case 'e':
142: flags |= OCCULT;
143: continue;
144:
145: case 'l':
146: flags |= LATUD;
147: continue;
148:
149: case 'm':
150: flags |= MEAN;
151: continue;
152:
153: case 'n':
154: flags |= GOOBIE;
155:
156: case 'p':
157: flags |= NOSTAR;
158: continue;
159:
160: case 's':
161: flags |= STCATL;
162: continue;
163: case 'x':
164: flags |= XYZ;
165: continue;
166:
167: case 'g':
168: flags |= GEO;
169: continue;
170:
171: case 'h':
172: flags |= HELIO;
173: continue;
174:
175: case 'c':
176: flags |= ECLIPTIC;
177: continue;
178:
179: case '-':
180: continue;
181:
182: default:
183: printf("Unknown option '%c'\n",p[-1]);
184: }
185: if(!((flags&GEO)||(flags&HELIO))){
186: flags |= TOPO;
187: }
188:
189: }
190:
191: readlat()
192: {
193: register i;
194: double ifa[3];
195:
196: printf("NLat(deg) WLong(deg) elev(meters)\n");
197: rline(stdin);
198: for(i=0; i<3; i++)
199: ifa[i] = atof(skip(i));
200: nlat = ifa[0] * radian;
201: wlong = ifa[1] * radian;
202: elev = ifa[2];
203: }
204:
205: readcat()
206: {
207: char *gets();
208: char *p;
209:
210: printf("Enter name of star catalog: ");
211: p = startab;
212: gets(p);
213: }
214:
215: init()
216: {
217:
218: register char *p, *q;
219:
220: wlong = (74.+32./60.)*radian;
221: nlat = (40.+40./60.)*radian;
222: elev = 0.;
223: if(flags & LATUD)
224: readlat();
225: prlat();
226: glat = nlat - (692.74*radsec)*sin(2.*nlat)
227: + (1.16*radsec)*sin(4.*nlat);
228: erad = .99832707 + .00167644*cos(2.*nlat)
229: - 0.352e-5*cos(4.*nlat)
230: + 0.001e-5*cos(6.*nlat)
231: + 0.1568e-6*elev;
232: q = "/usr/lib/startab";
233: for(p = startab; *p++ = *q++;)
234: ;
235: if(flags & STCATL)
236: readcat();
237: /*
238: printf("%s\n", startab);
239: */
240: }
241: rline(f)
242: FILE *f;
243: {
244: register char *p;
245: register c;
246:
247: p = line;
248: do {
249: c = getc(f);
250: if(c < 0)
251: return(1);
252: *p++ = c;
253: } while(c != '\n');
254: return(0);
255: }
256:
257: char*
258: skip(n)
259: {
260: register i;
261: register char *cp;
262:
263: cp = line;
264: for(i=0; i<n; i++) {
265: while(*cp == ' ' || *cp == '\t')
266: cp++;
267: while(*cp != '\n' && *cp != ' ' && *cp != '\t')
268: cp++;
269: }
270: while(*cp == ' ' || *cp == '\t')
271: cp++;
272: return(cp);
273: }
274: double
275: readate()
276: {
277: register i;
278: double ifa[5];
279:
280: printf("year mo da hr min\n");
281: if(rline(stdin) != 0)
282: exit(0);
283: for(i=0; i<5; i++)
284: ifa[i] = atof(skip(i));
285: return(convdate(ifa));
286: }
287:
288: double
289: convdate(ifa)
290: double ifa[];
291: {
292: double y, d, temp;
293: register i;
294:
295: y = ifa[0];
296: i = ifa[1];
297: d = ifa[2];
298: temp = 0.;
299: if(d>28.){
300: temp = d - 28.;
301: d = 28.;
302: }
303: while(i < 1) {
304: i += 12;
305: y -= 1.;
306: }
307: while(i > 12) {
308: i -= 12;
309: y += 1.;
310: }
311: if(y < 0.)
312: y += 1.;
313: y += 4712.;
314: if(fmod(y, 4.) == 0 && i > 2)
315: d += 1.;
316: y = y*365. +
317: floor((y+3.)/4.) +
318: dmo[i-1] + d - 1.;
319: if(y > 2361232.)
320: y -= floor((y-1794167.)/36525.) -
321: floor((y-1721117.)/146100.);
322: y += ifa[3]/24. + ifa[4]/1440. - .5 + temp;
323: return(y-2415020.);
324: }
325: setime(day)
326: double day;
327: {
328:
329:
330: eday = day;
331: deltat = eday * .00167;
332: glong = wlong;
333: if(flags & OCCULT)
334: glong += 15.*deltat*radsec;
335: capt = eday/36525.;
336: capt2 = capt*capt;
337: capt3 = capt2*capt;
338: nutate();
339:
340: aberr();
341:
342: sun();
343: xms = rad*cos(beta)*cos(lambda);
344: yms = rad*cos(beta)*sin(lambda);
345: zms = rad*sin(beta);
346: }
347:
348: double
349: fmod(x, y)
350: double x, y;
351: {
352: extern double modf();
353: double d;
354:
355: if (y == 0.0)
356: return (x);
357: modf(x/y, &d);
358: return (x - d * y);
359: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.