POV-Ray : Newsgroups : povray.advanced-users : Random tree position, without duplicates? : Re: Random tree position, without duplicates? Server Time: 27 Sep 2020 20:10:02 GMT
  Re: Random tree position, without duplicates?  
From: Edouard
Date: 4 Jun 2010 21:30:00
SharkD <mik### [at] gmailcom> wrote:
> Is there a good way to, for instance, place a number of trees randomly
> without having them overlap?
> Currently, I use an array to store the positions and compare each new
> tree to all the previous ones. This is however very slow.

I'd start with a halton sequence (I find myself using them everywhere...) and
seeing if it does a better job of not overlapping the trees:

#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;


#macro halton2D( n )
 #local baseX = 2;
 #local baseY = 3;

 < halton( n, baseX ), halton( n, baseY ), halton( n, baseZ ) >

You additionally take the values returned by the halton2D() macro, and test them
against a pigment function to decide whether to place a tree - this would give
you non-overlapping randomness on the small scale, and some clumping of trees on
the larger scale. My guess is that that would look quite natural, but you'd have
to give it a try to find out.


Post a reply to this message

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