29 |
|
int verbose = 0; /* verbose reporting */ |
30 |
|
char *progname; /* global argv[0] */ |
31 |
|
|
32 |
+ |
double threshold = 0.; /* glare threshold */ |
33 |
+ |
|
34 |
|
int sampdens = SAMPDENS; /* sample density */ |
35 |
|
ANGLE glarang[180] = {AEND}; /* glare calculation angles */ |
36 |
|
int nglarangs = 0; |
59 |
|
continue; |
60 |
|
} |
61 |
|
switch (argv[i][1]) { |
62 |
+ |
case 't': |
63 |
+ |
threshold = atof(argv[++i]); |
64 |
+ |
break; |
65 |
|
case 'r': |
66 |
|
sampdens = atoi(argv[++i])/2; |
67 |
|
break; |
173 |
|
exit(1); |
174 |
|
} |
175 |
|
init(); /* initialize program */ |
176 |
< |
comp_thresh(); /* compute glare threshold */ |
176 |
> |
if (threshold <= FTINY) |
177 |
> |
comp_thresh(); /* compute glare threshold */ |
178 |
|
analyze(); /* analyze view */ |
179 |
|
cleanup(); /* tidy up */ |
180 |
|
/* print header */ |
204 |
|
/* set direction vectors */ |
205 |
|
for (i = 0; glarang[i] != AEND; i++) |
206 |
|
; |
207 |
< |
if (i > 0 && glarang[0] <= 0 || glarang[i-1] >= 180) { |
207 |
> |
if (i > 0 && (glarang[0] <= 0 || glarang[i-1] >= 180)) { |
208 |
|
fprintf(stderr, "%s: glare angles must be between 1 and 179\n", |
209 |
|
progname); |
210 |
|
exit(1); |
231 |
|
setview(&rightview); |
232 |
|
indirect[nglarangs].lcos = |
233 |
|
indirect[nglarangs].rcos = cos(maxtheta); |
234 |
< |
indirect[nglarangs].lsin = |
235 |
< |
-(indirect[nglarangs].rsin = sin(maxtheta)); |
234 |
> |
indirect[nglarangs].rsin = |
235 |
> |
-(indirect[nglarangs].lsin = sin(maxtheta)); |
236 |
|
indirect[nglarangs].theta = 0.0; |
237 |
|
for (i = 0; i < nglarangs; i++) { |
238 |
|
d = (glarang[nglarangs-1] - glarang[i])*(PI/180.); |
239 |
|
indirect[nglarangs-i-1].lcos = |
240 |
|
indirect[nglarangs+i+1].rcos = cos(d); |
241 |
< |
indirect[nglarangs-i-1].lsin = |
242 |
< |
-(indirect[nglarangs+i+1].rsin = sin(d)); |
241 |
> |
indirect[nglarangs+i+1].rsin = |
242 |
> |
-(indirect[nglarangs-i-1].lsin = sin(d)); |
243 |
|
d = (glarang[nglarangs-1] + glarang[i])*(PI/180.); |
244 |
|
indirect[nglarangs-i-1].rcos = |
245 |
|
indirect[nglarangs+i+1].lcos = cos(d); |
246 |
< |
indirect[nglarangs+i+1].lsin = |
247 |
< |
-(indirect[nglarangs-i-1].rsin = sin(d)); |
248 |
< |
indirect[nglarangs-i-1].theta = -(PI/180.)*glarang[i]; |
249 |
< |
indirect[nglarangs+i+1].theta = (PI/180.)*glarang[i]; |
246 |
> |
indirect[nglarangs-i-1].rsin = |
247 |
> |
-(indirect[nglarangs+i+1].lsin = sin(d)); |
248 |
> |
indirect[nglarangs-i-1].theta = (PI/180.)*glarang[i]; |
249 |
> |
indirect[nglarangs+i+1].theta = -(PI/180.)*glarang[i]; |
250 |
|
} |
251 |
|
/* open picture */ |
252 |
|
if (picture != NULL) { |
301 |
|
} |
302 |
|
|
303 |
|
|
298 |
– |
spinvector(vres, vorig, vnorm, theta) /* rotate vector around normal */ |
299 |
– |
FVECT vres, vorig, vnorm; |
300 |
– |
double theta; |
301 |
– |
{ |
302 |
– |
extern double sin(), cos(); |
303 |
– |
double sint, cost, dotp; |
304 |
– |
FVECT vperp; |
305 |
– |
register int i; |
306 |
– |
|
307 |
– |
sint = sin(theta); |
308 |
– |
cost = cos(theta); |
309 |
– |
dotp = DOT(vorig, vnorm); |
310 |
– |
fcross(vperp, vnorm, vorig); |
311 |
– |
for (i = 0; i < 3; i++) |
312 |
– |
vres[i] = vnorm[i]*dotp*(1.-cost) + |
313 |
– |
vorig[i]*cost + vperp[i]*sint; |
314 |
– |
} |
315 |
– |
|
316 |
– |
|
304 |
|
memerr(s) /* malloc failure */ |
305 |
|
char *s; |
306 |
|
{ |
328 |
|
|
329 |
|
printf("BEGIN indirect illuminance\n"); |
330 |
|
for (i = 0; i < nglardirs; i++) |
331 |
< |
printf("\t%.0f\t%f\n", (180.0/PI)*indirect[i].theta, |
332 |
< |
PI * indirect[i].sum / (double)indirect[i].n); |
331 |
> |
if (indirect[i].n > FTINY) |
332 |
> |
printf("\t%.0f\t%f\n", (180.0/PI)*indirect[i].theta, |
333 |
> |
PI * indirect[i].sum / indirect[i].n); |
334 |
|
printf("END indirect illuminance\n"); |
335 |
|
} |