| 1 |
/* Copyright (c) 1991 Regents of the University of California */
|
| 2 |
|
| 3 |
#ifndef lint
|
| 4 |
static char SCCSid[] = "$SunId$ LBL";
|
| 5 |
#endif
|
| 6 |
|
| 7 |
/*
|
| 8 |
* Binary space partitioning curve for multidimensional sampling.
|
| 9 |
*
|
| 10 |
* Written by Christophe Schlick
|
| 11 |
*/
|
| 12 |
|
| 13 |
multisamp(t, n, r) /* convert 1-dimensional sample to N dimensions */
|
| 14 |
double t[]; /* returned N-dimensional vector */
|
| 15 |
register int n; /* number of dimensions */
|
| 16 |
double r; /* 1-dimensional sample [0,1) */
|
| 17 |
{
|
| 18 |
int j;
|
| 19 |
register int i, k;
|
| 20 |
int ti[8];
|
| 21 |
double s;
|
| 22 |
|
| 23 |
i = n;
|
| 24 |
while (i-- > 0)
|
| 25 |
ti[i] = 0;
|
| 26 |
j = 8;
|
| 27 |
while (j--) {
|
| 28 |
k = s = r*(1<<n);
|
| 29 |
r = s - k;
|
| 30 |
i = n;
|
| 31 |
while (i-- > 0)
|
| 32 |
ti[i] += ti[i] + ((k>>i) & 1);
|
| 33 |
}
|
| 34 |
i = n;
|
| 35 |
while (i-- > 0)
|
| 36 |
t[i] = 1./256. * ti[i];
|
| 37 |
}
|