ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/multisamp.c
Revision: 2.6
Committed: Wed Apr 17 15:07:29 2024 UTC (12 months, 2 weeks ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 2.5: +6 -7 lines
Log Message:
chore: ansification

File Contents

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