POV-Ray : Newsgroups : povray.advanced-users : Random tree position, without duplicates? : Re: Random tree position, without duplicates? Server Time
26 Apr 2024 02:17:38 EDT (-0400)
  Re: Random tree position, without duplicates?  
From: Jim Charter
Date: 5 Jun 2010 15:18:39
Message: <4c0aa30f$1@news.povray.org>
Edouard wrote:
> 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.
> 
> 
This is very useful! I see that the increasing integer eliminates the 
overlap of points.  Is there a relationship between the size of the 
object and the size of the increment that can be used to prevent 
objects intersecting?


Post a reply to this message

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