| 278 |
|
{ |
| 279 |
|
extern int ambcmp(); |
| 280 |
|
extern double sin(), cos(), sqrt(); |
| 281 |
+ |
int hlist[4]; |
| 282 |
|
double phi, xd, yd, zd; |
| 283 |
|
double b, b2; |
| 284 |
|
register AMBSAMP *div; |
| 313 |
|
fcross(ux, r->ron, uy); |
| 314 |
|
normalize(ux); |
| 315 |
|
fcross(uy, ux, r->ron); |
| 316 |
+ |
/* set up urand */ |
| 317 |
+ |
hlist[0] = r->rno; |
| 318 |
|
/* sample divisions */ |
| 319 |
|
arad = 0.0; |
| 320 |
|
ne = 0; |
| 321 |
< |
for (i = 0; i < nt; i++) |
| 321 |
> |
for (i = 0; i < nt; i++) { |
| 322 |
> |
hlist[1] = i; |
| 323 |
|
for (j = 0; j < np; j++) { |
| 324 |
|
rayorigin(&ar, r, AMBIENT, 0.5); /* pretested */ |
| 325 |
< |
zd = sqrt((i+frandom())/nt); |
| 326 |
< |
phi = 2.0*PI * (j+frandom())/np; |
| 325 |
> |
hlist[2] = j; |
| 326 |
> |
hlist[3] = 0; |
| 327 |
> |
zd = sqrt((i+urand(ilhash(hlist,4)))/nt); |
| 328 |
> |
hlist[3] = 1; |
| 329 |
> |
phi = 2.0*PI * (j+urand(ilhash(hlist,4)))/np; |
| 330 |
|
xd = cos(phi) * zd; |
| 331 |
|
yd = sin(phi) * zd; |
| 332 |
|
zd = sqrt(1.0 - zd*zd); |
| 333 |
|
for (k = 0; k < 3; k++) |
| 334 |
|
ar.rdir[k] = xd*ux[k]+yd*uy[k]+zd*r->ron[k]; |
| 335 |
+ |
dimlist[ndims++] = i*np + j + 38813; |
| 336 |
|
rayvalue(&ar); |
| 337 |
+ |
ndims--; |
| 338 |
|
if (ar.rot < FHUGE) |
| 339 |
|
arad += 1.0 / ar.rot; |
| 340 |
|
if (ns > 0) { /* save division */ |
| 372 |
|
} else |
| 373 |
|
addcolor(acol, ar.rcol); |
| 374 |
|
} |
| 375 |
+ |
} |
| 376 |
|
for (k = 0; k < ne; k++) { /* compute errors */ |
| 377 |
|
if (div[k].n > 1) |
| 378 |
|
div[k].k /= div[k].n; |
| 388 |
|
/* super-sample */ |
| 389 |
|
for (i = ns; i > 0; i--) { |
| 390 |
|
rayorigin(&ar, r, AMBIENT, 0.5); /* pretested */ |
| 391 |
< |
zd = sqrt((div[0].t+frandom())/nt); |
| 392 |
< |
phi = 2.0*PI * (div[0].p+frandom())/np; |
| 391 |
> |
hlist[1] = div[0].t; |
| 392 |
> |
hlist[2] = div[0].p; |
| 393 |
> |
hlist[3] = 0; |
| 394 |
> |
zd = sqrt((div[0].t+urand(ilhash(hlist,4)+div[0].n))/nt); |
| 395 |
> |
hlist[3] = 1; |
| 396 |
> |
phi = 2.0*PI * (div[0].p+urand(ilhash(hlist,4)+div[0].n))/np; |
| 397 |
|
xd = cos(phi) * zd; |
| 398 |
|
yd = sin(phi) * zd; |
| 399 |
|
zd = sqrt(1.0 - zd*zd); |
| 400 |
|
for (k = 0; k < 3; k++) |
| 401 |
|
ar.rdir[k] = xd*ux[k]+yd*uy[k]+zd*r->ron[k]; |
| 402 |
+ |
dimlist[ndims++] = div[0].t*np + div[0].p + 38813; |
| 403 |
+ |
rayvalue(&ar); |
| 404 |
+ |
ndims--; |
| 405 |
|
rayvalue(&ar); |
| 406 |
|
if (ar.rot < FHUGE) |
| 407 |
|
arad += 1.0 / ar.rot; |