29 |
|
int verbose = 0; /* verbose reporting */ |
30 |
|
char *progname; /* global argv[0] */ |
31 |
|
|
32 |
+ |
int sampdens = SAMPDENS; /* sample density */ |
33 |
|
ANGLE glarang[180] = {AEND}; /* glare calculation angles */ |
34 |
|
int nglarangs = 0; |
35 |
|
double maxtheta; /* maximum angle (in radians) */ |
57 |
|
continue; |
58 |
|
} |
59 |
|
switch (argv[i][1]) { |
60 |
+ |
case 'r': |
61 |
+ |
sampdens = atoi(argv[++i])/2; |
62 |
+ |
break; |
63 |
|
case 'v': |
64 |
|
if (argv[i][2] == '\0') { |
65 |
|
verbose++; |
205 |
|
} |
206 |
|
nglarangs = i; |
207 |
|
/* nglardirs = 2*nglarangs + 1; */ |
208 |
< |
/* vsize = SAMPDENS; */ |
208 |
> |
/* vsize = sampdens - 1; */ |
209 |
|
if (nglarangs > 0) |
210 |
|
maxtheta = (PI/180.)*glarang[nglarangs-1]; |
211 |
|
else |
212 |
|
maxtheta = 0.0; |
213 |
< |
hlim = SAMPDENS*maxtheta; |
214 |
< |
hsize = SAMPDENS + hlim; |
215 |
< |
if (hsize > (int)(PI*SAMPDENS)) |
216 |
< |
hsize = PI*SAMPDENS; |
213 |
> |
hlim = sampdens*maxtheta; |
214 |
> |
hsize = hlim + sampdens - 1; |
215 |
> |
if (hsize > (int)(PI*sampdens)) |
216 |
> |
hsize = PI*sampdens; |
217 |
|
indirect = (struct illum *)calloc(nglardirs, sizeof(struct illum)); |
218 |
|
if (indirect == NULL) |
219 |
|
memerr("indirect illuminances"); |
220 |
|
copystruct(&leftview, &ourview); |
221 |
|
copystruct(&rightview, &ourview); |
222 |
< |
spinvector(leftview.vdir, ourview.vdir, ourview.vup, -maxtheta); |
223 |
< |
spinvector(rightview.vdir, ourview.vdir, ourview.vup, maxtheta); |
222 |
> |
spinvector(leftview.vdir, ourview.vdir, ourview.vup, maxtheta); |
223 |
> |
spinvector(rightview.vdir, ourview.vdir, ourview.vup, -maxtheta); |
224 |
|
setview(&leftview); |
225 |
|
setview(&rightview); |
226 |
|
indirect[nglarangs].lcos = |
281 |
|
|
282 |
|
if (x <= -hlim) /* left region */ |
283 |
|
return(viewray(org, vd, &leftview, |
284 |
< |
(x+hlim)/(2.*SAMPDENS)+.5, |
285 |
< |
y/(2.*SAMPDENS)+.5)); |
284 |
> |
(x+hlim)/(2.*sampdens)+.5, |
285 |
> |
y/(2.*sampdens)+.5)); |
286 |
|
if (x >= hlim) /* right region */ |
287 |
|
return(viewray(org, vd, &rightview, |
288 |
< |
(x-hlim)/(2.*SAMPDENS)+.5, |
289 |
< |
y/(2.*SAMPDENS)+.5)); |
288 |
> |
(x-hlim)/(2.*sampdens)+.5, |
289 |
> |
y/(2.*sampdens)+.5)); |
290 |
|
/* central region */ |
291 |
< |
if (viewray(org, vd, &ourview, .5, y/(2.*SAMPDENS)+.5) < 0) |
291 |
> |
if (viewray(org, vd, &ourview, .5, y/(2.*sampdens)+.5) < 0) |
292 |
|
return(-1); |
293 |
|
spinvector(vd, vd, ourview.vup, h_theta(x)); |
294 |
|
return(0); |
317 |
|
memerr(s) /* malloc failure */ |
318 |
|
char *s; |
319 |
|
{ |
320 |
< |
fprintf(stderr, "%s: out of memory for %s\n", s); |
320 |
> |
fprintf(stderr, "%s: out of memory for %s\n", progname, s); |
321 |
|
exit(1); |
322 |
|
} |
323 |
|
|
341 |
|
|
342 |
|
printf("BEGIN indirect illuminance\n"); |
343 |
|
for (i = 0; i < nglardirs; i++) |
344 |
< |
printf("\t%f\t%f\n", (180.0/PI)*indirect[i].theta, |
344 |
> |
printf("\t%.0f\t%f\n", (180.0/PI)*indirect[i].theta, |
345 |
|
PI * indirect[i].sum / (double)indirect[i].n); |
346 |
|
printf("END indirect illuminance\n"); |
347 |
|
} |