ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/multisamp.c
Revision: 2.2
Committed: Mon Dec 1 09:54:59 1997 UTC (26 years, 5 months ago) by gregl
Content type: text/plain
Branch: MAIN
Changes since 2.1: +5 -3 lines
Log Message:
added define to eliminate initurand() reference for -DMC

File Contents

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