POV-Ray : Newsgroups : povray.advanced-users : Random tree position, without duplicates? : Re: Random tree position, without duplicates? Server Time: 28 Sep 2020 22:17:53 GMT
  Re: Random tree position, without duplicates?  
From: Edouard
Date: 5 Jun 2010 00:10:00
SharkD <mik### [at] gmailcom> wrote:
> On 6/4/2010 5:31 PM, Edouard wrote:
> > "Edouard"<pov### [at] edouardinfo>  wrote:
> >
> > Opps - I mean:
> >
> > #macro halton2D( n )
> >   #local baseX = 2;
> >   #local baseY = 3;
> >
> >   <  halton( n, baseX ), halton( n, baseY ), 0>
> > #end
>
>
> Could you provide an example of how to use it? Thanks.

I'll try!

The halton macro returns a number from 0..1, and halton2D() returns a vector
where the X is 0..1, Y is 0..1 and the Z = 0.

You call halton2D() with an incrementing integer, so it works best in a loop.

If you had a macro called PlaceTree(), you could loop through values from
halton2D calling the tree macro like this:

#declare n = 1;
#while( n < number_of_trees_wanted )
  #declare position = halton2D( n );
  // position is <0..1, 0..1, 0> - scale the vector here
  // to the size you need for PlaceTree
  PlaceTree( position )
  #declare n = n + 1;
#end

Does my explanation make sense?

Cheers,
Edouard.


Post a reply to this message

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