1 |
< |
/* Copyright (c) 1986 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1992 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
19 |
|
|
20 |
|
#include "color.h" |
21 |
|
|
22 |
– |
#ifndef atof |
23 |
– |
extern double atof(); |
24 |
– |
#endif |
22 |
|
extern char *strcpy(), *strcat(), *malloc(); |
23 |
|
extern double stadj(), sdec(), sazi(), salt(); |
24 |
|
|
46 |
|
double sundir[3]; |
47 |
|
double groundbr; |
48 |
|
double F2; |
49 |
< |
double solarbr; |
49 |
> |
double solarbr = -1.0; |
50 |
|
|
51 |
|
char *progname; |
52 |
|
char errmsg[128]; |
88 |
|
cloudy = 0; |
89 |
|
dosun = argv[i][0] == '+'; |
90 |
|
break; |
91 |
+ |
case 'r': |
92 |
+ |
solarbr = atof(argv[++i]); |
93 |
+ |
break; |
94 |
|
case 'c': |
95 |
|
cloudy = argv[i][0] == '+' ? 2 : 1; |
96 |
|
dosun = 0; |
148 |
|
altitude = salt(sd, st); |
149 |
|
azimuth = sazi(sd, st); |
150 |
|
} |
151 |
+ |
if (!cloudy && altitude > 87.*PI/180.) { |
152 |
+ |
fprintf(stderr, |
153 |
+ |
"%s: warning - sun too close to zenith, reducing altitude to 87 degrees\n", |
154 |
+ |
progname); |
155 |
+ |
printf( |
156 |
+ |
"# warning - sun too close to zenith, reducing altitude to 87 degrees\n"); |
157 |
+ |
altitude = 87.*PI/180.; |
158 |
+ |
} |
159 |
|
sundir[0] = -sin(azimuth)*cos(altitude); |
160 |
|
sundir[1] = -cos(azimuth)*cos(altitude); |
161 |
|
sundir[2] = sin(altitude); |
183 |
|
0.45*sundir[2]*sundir[2]); |
184 |
|
groundbr = zenithbr*normsc(altitude)/F2/PI; |
185 |
|
printf("# Ground ambient level: %f\n", groundbr); |
186 |
< |
if (sundir[2] > 0.0) { |
187 |
< |
if (sundir[2] > .16) |
188 |
< |
solarbr = (1.5e9/SUNEFFICACY) * |
189 |
< |
(1.147 - .147/sundir[2]); |
182 |
< |
else |
183 |
< |
solarbr = 1.5e9/SUNEFFICACY*(1.147-.147/.16); |
186 |
> |
if (sundir[2] > 0.0 && solarbr != 0.0) { |
187 |
> |
if (solarbr < 0.0) |
188 |
> |
solarbr = 1.5e9/SUNEFFICACY * |
189 |
> |
(1.147 - .147/(sundir[2]>.16?sundir[2]:.16)); |
190 |
|
groundbr += solarbr*6e-5*sundir[2]/PI; |
191 |
|
} else |
192 |
|
dosun = 0; |