ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/brandom.c
Revision: 1.2
Committed: Sat Feb 22 02:07:27 2003 UTC (21 years, 1 month ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R6P1, rad3R5, rad3R6
Changes since 1.1: +1 -4 lines
Log Message:
Changes and check-in for 3.5 release
Includes new source files and modifications not recorded for many years
See ray/doc/notes/ReleaseNotes for notes between 3.1 and 3.5 release

File Contents

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