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) */ |
36 |
|
int hsize; /* horizontal size */ |
37 |
|
int hlim; /* central limit of horizontal */ |
38 |
|
|
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++; |
198 |
|
/* set direction vectors */ |
199 |
|
for (i = 0; glarang[i] != AEND; i++) |
200 |
|
; |
201 |
< |
if (glarang[0] <= 0 || glarang[i-1] >= 180) { |
201 |
> |
if (i > 0 && glarang[0] <= 0 || glarang[i-1] >= 180) { |
202 |
|
fprintf(stderr, "%s: glare angles must be between 1 and 179\n", |
203 |
|
progname); |
204 |
|
exit(1); |
205 |
|
} |
206 |
|
nglarangs = i; |
207 |
|
/* nglardirs = 2*nglarangs + 1; */ |
208 |
< |
/* maxtheta = (PI/180.)*glarang[nglarangs-1]; */ |
209 |
< |
/* vsize = SAMPDENS; */ |
210 |
< |
hlim = SAMPDENS*maxtheta; |
211 |
< |
hsize = SAMPDENS + hlim; |
212 |
< |
if (hsize > (int)(PI*SAMPDENS)) |
213 |
< |
hsize = PI*SAMPDENS; |
208 |
> |
/* vsize = sampdens; */ |
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; |
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); |
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 illuminances\n"); |
346 |
> |
printf("END indirect illuminance\n"); |
347 |
|
} |