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:
parent
acd65a4212
commit
9c070e4f9b
@ -63,10 +63,13 @@ static void draw_level ( int num, double m00, double m01, double m10, double m11
|
||||
|
||||
for ( i = 0; i < 10; i++ )
|
||||
{
|
||||
int random = (rand() >> 10) % num_trans;
|
||||
double new_x = affine[random].a00 * current_x + affine[random].a01 * current_y + affine[random].b0 ;
|
||||
double new_y = affine[random].a10 * current_x + affine[random].a11 * current_y + affine[random].b1 ;
|
||||
|
||||
int random = rand( );
|
||||
double new_x;
|
||||
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 ) ;
|
||||
current_x = new_x ;
|
||||
current_y = new_y ;
|
||||
|
Reference in New Issue
Block a user