36 |
|
int nglarangs = 0; |
37 |
|
double maxtheta; /* maximum angle (in radians) */ |
38 |
|
int hsize; /* horizontal size */ |
39 |
– |
int hlim; /* central limit of horizontal */ |
39 |
|
|
40 |
|
struct illum *indirect; /* array of indirect illuminances */ |
41 |
|
|
226 |
|
maxtheta = (PI/180.)*glarang[nglarangs-1]; |
227 |
|
else |
228 |
|
maxtheta = 0.0; |
229 |
< |
hlim = sampdens*maxtheta; |
231 |
< |
hsize = hlim + sampdens - 1; |
229 |
> |
hsize = hlim(0) + sampdens - 1; |
230 |
|
if (hsize > (int)(PI*sampdens)) |
231 |
|
hsize = PI*sampdens; |
232 |
|
indirect = (struct illum *)calloc(nglardirs, sizeof(struct illum)); |
292 |
|
} |
293 |
|
|
294 |
|
|
295 |
< |
compdir(vd, x, y, se) /* compute direction for x,y */ |
295 |
> |
compdir(vd, x, y) /* compute direction for x,y */ |
296 |
|
FVECT vd; |
297 |
|
int x, y; |
300 |
– |
SPANERR *se; |
298 |
|
{ |
299 |
+ |
int hl; |
300 |
|
FVECT org; /* dummy variable */ |
301 |
|
|
302 |
< |
if (x <= -hlim) /* left region */ |
302 |
> |
hl = hlim(y); |
303 |
> |
if (x <= -hl) /* left region */ |
304 |
|
return(viewray(org, vd, &leftview, |
305 |
< |
(double)(x+hlim)/(2*sampdens)+.5, |
305 |
> |
(double)(x+hl)/(2*sampdens)+.5, |
306 |
|
(double)y/(2*sampdens)+.5)); |
307 |
< |
if (x >= hlim) /* right region */ |
307 |
> |
if (x >= hl) /* right region */ |
308 |
|
return(viewray(org, vd, &rightview, |
309 |
< |
(double)(x-hlim)/(2*sampdens)+.5, |
309 |
> |
(double)(x-hl)/(2*sampdens)+.5, |
310 |
|
(double)y/(2*sampdens)+.5)); |
311 |
|
/* central region */ |
313 |
– |
if (se != NULL) { /* avoid over-counting of poles */ |
314 |
– |
se->err += se->prob; |
315 |
– |
if (se->err <= 0.5) |
316 |
– |
return(-1); |
317 |
– |
se->err -= 1.0; |
318 |
– |
} |
312 |
|
if (viewray(org, vd, &ourview, .5, (double)y/(2*sampdens)+.5) < 0) |
313 |
|
return(-1); |
314 |
< |
spinvector(vd, vd, ourview.vup, h_theta(x)); |
314 |
> |
spinvector(vd, vd, ourview.vup, h_theta(x,y)); |
315 |
|
return(0); |
316 |
|
} |
317 |
|
|
318 |
|
|
319 |
< |
setspanerr(se, y) /* initialize span error at y */ |
320 |
< |
register SPANERR *se; |
321 |
< |
int y; |
319 |
> |
double |
320 |
> |
pixsize(x, y) /* return the solid angle of pixel at (x,y) */ |
321 |
> |
int x, y; |
322 |
|
{ |
323 |
< |
se->err = 0.0; |
324 |
< |
se->prob = sqrt(1.0 - (double)((long)y*y)/((long)vsize*vsize)); |
323 |
> |
register int hl, xo; |
324 |
> |
double disc; |
325 |
> |
|
326 |
> |
hl = hlim(y); |
327 |
> |
if (x < -hl) |
328 |
> |
xo = x+hl; |
329 |
> |
else if (x > hl) |
330 |
> |
xo = x-hl; |
331 |
> |
else |
332 |
> |
xo = 0; |
333 |
> |
disc = 1. - (xo*xo + y*y)/(sampdens*sampdens); |
334 |
> |
if (disc <= FTINY) |
335 |
> |
return(0.); |
336 |
> |
return(1./(sampdens*sampdens*sqrt(disc))); |
337 |
|
} |
338 |
|
|
339 |
|
|