| 190 |
|
fputs(VIEWSTR, stdout); |
| 191 |
|
fprintview(&ourview, stdout); |
| 192 |
|
printf("\n"); |
| 193 |
< |
fputformat("ASCII", stdout); |
| 193 |
> |
fputformat("ascii", stdout); |
| 194 |
|
printf("\n"); |
| 195 |
|
printsources(); /* print glare sources */ |
| 196 |
|
printillum(); /* print illuminances */ |
| 203 |
|
} |
| 204 |
|
|
| 205 |
|
|
| 206 |
+ |
int |
| 207 |
+ |
angcmp(ap1, ap2) /* compare two angles */ |
| 208 |
+ |
ANGLE *ap1, *ap2; |
| 209 |
+ |
{ |
| 210 |
+ |
register int a1, a2; |
| 211 |
+ |
|
| 212 |
+ |
a1 = *ap1; |
| 213 |
+ |
a2 = *ap2; |
| 214 |
+ |
if (a1 == a2) { |
| 215 |
+ |
fprintf(stderr, "%s: duplicate glare angle (%d)\n", |
| 216 |
+ |
progname, a1); |
| 217 |
+ |
exit(1); |
| 218 |
+ |
} |
| 219 |
+ |
return(a1-a2); |
| 220 |
+ |
} |
| 221 |
+ |
|
| 222 |
+ |
|
| 223 |
|
init() /* initialize global variables */ |
| 224 |
|
{ |
| 225 |
|
double d; |
| 231 |
|
/* set direction vectors */ |
| 232 |
|
for (i = 0; glarang[i] != AEND; i++) |
| 233 |
|
; |
| 234 |
< |
if (i > 0 && (glarang[0] <= 0 || glarang[i-1] >= 180)) { |
| 235 |
< |
fprintf(stderr, "%s: glare angles must be between 1 and 179\n", |
| 234 |
> |
qsort(glarang, i, sizeof(ANGLE), angcmp); |
| 235 |
> |
if (i > 0 && (glarang[0] <= 0 || glarang[i-1] > 180)) { |
| 236 |
> |
fprintf(stderr, "%s: glare angles must be between 1 and 180\n", |
| 237 |
|
progname); |
| 238 |
|
exit(1); |
| 239 |
|
} |
| 318 |
|
FVECT org; /* dummy variable */ |
| 319 |
|
|
| 320 |
|
hl = hlim(y); |
| 321 |
< |
if (x <= -hl) /* left region */ |
| 321 |
> |
if (x <= -hl) { /* left region */ |
| 322 |
> |
if (x <= -hl-sampdens) |
| 323 |
> |
return(-1); |
| 324 |
|
return(viewray(org, vd, &leftview, |
| 325 |
|
(double)(x+hl)/(2*sampdens)+.5, |
| 326 |
|
(double)y/(2*sampdens)+.5)); |
| 327 |
< |
if (x >= hl) /* right region */ |
| 327 |
> |
} |
| 328 |
> |
if (x >= hl) { /* right region */ |
| 329 |
> |
if (x >= hl+sampdens) |
| 330 |
> |
return(-1); |
| 331 |
|
return(viewray(org, vd, &rightview, |
| 332 |
|
(double)(x-hl)/(2*sampdens)+.5, |
| 333 |
|
(double)y/(2*sampdens)+.5)); |
| 334 |
+ |
} |
| 335 |
|
/* central region */ |
| 336 |
|
if (viewray(org, vd, &ourview, .5, (double)y/(2*sampdens)+.5) < 0) |
| 337 |
|
return(-1); |
| 354 |
|
xo = x-hl; |
| 355 |
|
else |
| 356 |
|
xo = 0; |
| 357 |
< |
disc = 1. - (xo*xo + y*y)/(sampdens*sampdens); |
| 357 |
> |
disc = 1. - (double)(xo*xo + y*y)/(sampdens*sampdens); |
| 358 |
|
if (disc <= FTINY) |
| 359 |
|
return(0.); |
| 360 |
|
return(1./(sampdens*sampdens*sqrt(disc))); |