ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/multisamp.c
Revision: 2.7
Committed: Tue Jul 2 18:04:08 2024 UTC (9 months, 4 weeks ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 2.6: +3 -1 lines
Log Message:
fix: Added facility for handling > 8 dimensions

File Contents

# Content
1 #ifndef lint
2 static const char RCSid[] = "$Id: multisamp.c,v 2.6 2024/04/17 15:07:29 greg Exp $";
3 #endif
4 /*
5 * Binary space partitioning curve for multidimensional sampling.
6 *
7 * Written by Christophe Schlick
8 */
9
10 #include "copyright.h"
11
12 #include <stdlib.h>
13
14 #include "random.h"
15
16
17 /* Convert 1-dimensional sample to N dimensions */
18 void
19 multisamp(double t[], int n, double r)
20 {
21 int j;
22 int i, k;
23 int ti[8];
24 double s;
25
26 while (n > 8)
27 t[--n] = frandom();
28 i = n;
29 while (i-- > 0)
30 ti[i] = 0;
31 j = 8;
32 while (j--) {
33 k = s = r*(1<<n);
34 r = s - k;
35 i = n;
36 while (i-- > 0)
37 ti[i] += ti[i] + ((k>>i) & 1);
38 }
39 i = n;
40 while (i-- > 0)
41 t[i] = (1./256.) * (ti[i] + frandom());
42 }