Altered the way that the {random} value (from 0..3) is chosen.

Previously, it picked out two adjacent bits in the result of rand().
Unfortunately, these adjacent bits (at least on NetBSD) have a certain
amount of dependance.  After a period (perhaps a thousand or so?), it
starts to repeat the pattern of those two bits.  (I think; I haven't
actually tested that directly.)  This presumably is locking it into a
an an N-way attractor on the "snowflake", such that if you zoom in a
ways, you will start to see some spots *quickly* are colored, and
others are *never* colored.

What I've done now is to pick up two widely-spaced bits in a single
rand() call.  (Perhaps we would do as well to pick up something like
bit #16 from two consecutive rand() calls?)  These widely-spaced bits
have a lower statistical dependance on one another (if I can get away
with using that term for an arithmetic operation; though since stats
has more to do with sampling and less to do with true randomness, I
may be safe).

The net effect, at leats on NetBSD, is far better snowflake if you zoom
in on it.


git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@324 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
rkrolib 2003-11-08 01:56:45 +00:00
parent acd65a4212
commit 9c070e4f9b

View File

@ -63,9 +63,12 @@ static void draw_level ( int num, double m00, double m01, double m10, double m11
for ( i = 0; i < 10; i++ ) for ( i = 0; i < 10; i++ )
{ {
int random = (rand() >> 10) % num_trans; int random = rand( );
double new_x = affine[random].a00 * current_x + affine[random].a01 * current_y + affine[random].b0 ; double new_x;
double new_y = affine[random].a10 * current_x + affine[random].a11 * current_y + affine[random].b1 ; double new_y;
random = (((random >> 10)) & 2) + (((random >> 20) ) & 1);
new_x = affine[random].a00 * current_x + affine[random].a01 * current_y + affine[random].b0 ;
new_y = affine[random].a10 * current_x + affine[random].a11 * current_y + affine[random].b1 ;
glVertex2d ( new_x, new_y ) ; glVertex2d ( new_x, new_y ) ;
current_x = new_x ; current_x = new_x ;