1 |
– |
/* Copyright (c) 1992 Regents of the University of California */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* gensky.c - program to generate sky functions. |
6 |
|
* Our zenith is along the Z-axis, the X-axis |
11 |
|
*/ |
12 |
|
|
13 |
|
#include <stdio.h> |
14 |
< |
|
14 |
> |
#include <stdlib.h> |
15 |
> |
#include <string.h> |
16 |
|
#include <math.h> |
19 |
– |
|
17 |
|
#include <ctype.h> |
18 |
|
|
19 |
|
#include "color.h" |
20 |
|
|
21 |
< |
extern char *strcpy(), *strcat(), *malloc(); |
22 |
< |
extern double stadj(), sdec(), sazi(), salt(), tz2mer(); |
21 |
> |
extern int jdate(int month, int day); |
22 |
> |
extern double stadj(int jd); |
23 |
> |
extern double sdec(int jd); |
24 |
> |
extern double salt(double sd, double st); |
25 |
> |
extern double sazi(double sd, double st); |
26 |
|
|
27 |
|
#ifndef PI |
28 |
|
#define PI 3.14159265358979323846 |
35 |
|
#define S_UNIF 3 |
36 |
|
#define S_INTER 4 |
37 |
|
|
38 |
< |
#define overcast (skytype==S_OVER|skytype==S_UNIF) |
38 |
> |
#define overcast ((skytype==S_OVER)|(skytype==S_UNIF)) |
39 |
|
|
40 |
|
double normsc(); |
41 |
|
/* sun calculation constants */ |
51 |
|
char zname[8]; /* time zone name (all caps) */ |
52 |
|
float zmer; /* standard meridian */ |
53 |
|
} tzone[] = { |
54 |
< |
"YST", 135, "YDT", 120, |
55 |
< |
"PST", 120, "PDT", 105, |
56 |
< |
"MST", 105, "MDT", 90, |
57 |
< |
"CST", 90, "CDT", 75, |
58 |
< |
"EST", 75, "EDT", 60, |
59 |
< |
"AST", 60, "ADT", 45, |
60 |
< |
"NST", 52.5, "NDT", 37.5, |
61 |
< |
"GMT", 0, "BST", -15, |
62 |
< |
"WET", -15, "WETDST", -30, |
63 |
< |
"MET", -30, "METDST", -45, |
64 |
< |
"MEZ", -30, "MESZ", -45, |
65 |
< |
"", 0 |
54 |
> |
{"YST", 135}, {"YDT", 120}, |
55 |
> |
{"PST", 120}, {"PDT", 105}, |
56 |
> |
{"MST", 105}, {"MDT", 90}, |
57 |
> |
{"CST", 90}, {"CDT", 75}, |
58 |
> |
{"EST", 75}, {"EDT", 60}, |
59 |
> |
{"AST", 60}, {"ADT", 45}, |
60 |
> |
{"NST", 52.5}, {"NDT", 37.5}, |
61 |
> |
{"GMT", 0}, {"BST", -15}, |
62 |
> |
{"CET", -15}, {"CEST", -30}, |
63 |
> |
{"EET", -30}, {"EEST", -45}, |
64 |
> |
{"AST", -45}, {"ADT", -60}, |
65 |
> |
{"GST", -60}, {"GDT", -75}, |
66 |
> |
{"IST", -82.5}, {"IDT", -97.5}, |
67 |
> |
{"JST", -135}, {"NDT", -150}, |
68 |
> |
{"NZST", -180}, {"NZDT", -195}, |
69 |
> |
{"", 0} |
70 |
|
}; |
71 |
|
/* required values */ |
72 |
|
int month, day; /* date */ |
90 |
|
char *progname; |
91 |
|
char errmsg[128]; |
92 |
|
|
93 |
+ |
void computesky(void); |
94 |
+ |
void printsky(void); |
95 |
+ |
void printdefaults(void); |
96 |
+ |
void userror(char *msg); |
97 |
+ |
double normsc(void); |
98 |
+ |
void cvthour(char *hs); |
99 |
+ |
void printhead(register int ac, register char **av); |
100 |
|
|
101 |
+ |
|
102 |
+ |
int |
103 |
|
main(argc, argv) |
104 |
|
int argc; |
105 |
|
char *argv[]; |
175 |
|
else |
176 |
|
userror("bad option"); |
177 |
|
|
178 |
< |
if (fabs(s_meridian-s_longitude) > 30*PI/180) |
178 |
> |
if (fabs(s_meridian-s_longitude) > 45*PI/180) |
179 |
|
fprintf(stderr, |
180 |
|
"%s: warning: %.1f hours btwn. standard meridian and longitude\n", |
181 |
|
progname, (s_longitude-s_meridian)*12/PI); |
189 |
|
} |
190 |
|
|
191 |
|
|
192 |
< |
computesky() /* compute sky parameters */ |
192 |
> |
void |
193 |
> |
computesky(void) /* compute sky parameters */ |
194 |
|
{ |
195 |
|
double normfactor; |
196 |
|
/* compute solar direction */ |
275 |
|
} |
276 |
|
|
277 |
|
|
278 |
< |
printsky() /* print out sky */ |
278 |
> |
void |
279 |
> |
printsky(void) /* print out sky */ |
280 |
|
{ |
281 |
|
if (dosun) { |
282 |
|
printf("\nvoid light solar\n"); |
299 |
|
} |
300 |
|
|
301 |
|
|
302 |
< |
printdefaults() /* print default values */ |
302 |
> |
void |
303 |
> |
printdefaults(void) /* print default values */ |
304 |
|
{ |
305 |
|
switch (skytype) { |
306 |
|
case S_OVER: |
333 |
|
} |
334 |
|
|
335 |
|
|
336 |
< |
userror(msg) /* print usage error and quit */ |
337 |
< |
char *msg; |
336 |
> |
void |
337 |
> |
userror( /* print usage error and quit */ |
338 |
> |
char *msg |
339 |
> |
) |
340 |
|
{ |
341 |
|
if (msg != NULL) |
342 |
|
fprintf(stderr, "%s: Use error - %s\n", progname, msg); |
348 |
|
|
349 |
|
|
350 |
|
double |
351 |
< |
normsc() /* compute normalization factor (E0*F2/L0) */ |
351 |
> |
normsc(void) /* compute normalization factor (E0*F2/L0) */ |
352 |
|
{ |
353 |
|
static double nfc[2][5] = { |
354 |
|
/* clear sky approx. */ |
370 |
|
} |
371 |
|
|
372 |
|
|
373 |
< |
cvthour(hs) /* convert hour string */ |
374 |
< |
char *hs; |
373 |
> |
void |
374 |
> |
cvthour( /* convert hour string */ |
375 |
> |
char *hs |
376 |
> |
) |
377 |
|
{ |
378 |
|
register char *cp = hs; |
379 |
|
register int i, j; |
380 |
|
|
381 |
< |
if (tsolar = *cp == '+') cp++; /* solar time? */ |
381 |
> |
if ( (tsolar = *cp == '+') ) cp++; /* solar time? */ |
382 |
|
while (isdigit(*cp)) cp++; |
383 |
|
if (*cp == ':') |
384 |
|
hour = atoi(hs) + atoi(++cp)/60.0; |
413 |
|
} |
414 |
|
|
415 |
|
|
416 |
< |
printhead(ac, av) /* print command header */ |
417 |
< |
register int ac; |
418 |
< |
register char **av; |
416 |
> |
void |
417 |
> |
printhead( /* print command header */ |
418 |
> |
register int ac, |
419 |
> |
register char **av |
420 |
> |
) |
421 |
|
{ |
422 |
|
putchar('#'); |
423 |
|
while (ac--) { |