ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/brandom.c
Revision: 1.1
Committed: Thu Feb 2 10:49:07 1989 UTC (35 years, 3 months ago) by greg
Content type: text/plain
Branch: MAIN
Log Message:
Initial revision

File Contents

# Content
1 /* Copyright (c) 1986 Regents of the University of California */
2
3 #ifndef lint
4 static char SCCSid[] = "$SunId$ LBL";
5 #endif
6
7 /*
8 * brandom.c - blue noise function.
9 *
10 * 11/8/87
11 */
12
13 #include "random.h"
14
15
16 double
17 brandom(l) /* blue noise function */
18 int l; /* length between 1 and 8 */
19 {
20 static float his[8] = {.5,.5,.5,.5,.5,.5,.5,.5};
21 static double avg = .5;
22 static int x = 0;
23 double y = frandom();
24
25 if (avg < .5)
26 y = 1 - 2*y*avg;
27 else
28 y = 2*y*(1 - avg);
29 /* update */
30 avg += (y - his[x])/l;
31 his[x] = y;
32 if (++x >= l) x = 0;
33
34 return(y);
35 }