POV-Ray : Newsgroups : povray.binaries.images : Alley Sunflower WIP : Re: Alley Sunflower WIP Server Time
2 Nov 2024 18:52:32 EDT (-0400)
  Re: Alley Sunflower WIP  
From: Edouard
Date: 28 Apr 2010 01:35:02
Message: <web.4bd7c8a9f8dc137b21619a220@news.povray.org>
"Nekar Xenos" <nek### [at] gmailcom> wrote:

> I have 5 different mesh bricks, randomly mirrored and rotated, but
> I still get 3 of the same bricks in a row. Any ideas on how to get it more
> random?

Ahh - I came across this problem several times in the past, and I ended up
learning about low-discrepancy sequences - which are completely non-random, but
more "randomly" distributed than a real random sequence.

My code for a halton sequence is:

#macro halton( index, base )
 #local out = 0.0;
 #local fraction = 1.0 / base;
 #local i = index;
 #while( i > 0 )
  #local remainder = mod( i, base );
  #local out = out + (fraction * remainder);
  #local i = int(i / base);
  #local fraction = fraction / base;
 #end

 out
#end

The base value is a prime number (the smaller the better), and the index can be
your brick number.

Get a value out of it with "halton( brick_number, 2 )".

> Suggestions, help and critique welcome.
>
> -Nekar Xenos-

Cheers,
Edouard.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.