POV-Ray : Newsgroups : povray.advanced-users : Random tree position, without duplicates? : Re: Random tree position, without duplicates? Server Time
26 Apr 2024 23:17:11 EDT (-0400)
  Re: Random tree position, without duplicates?  
From: Edouard
Date: 4 Jun 2010 20:10:00
Message: <web.4c0994e4295829f03694f4200@news.povray.org>
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-2023 Persistence of Vision Raytracer Pty. Ltd.