POV-Ray : Newsgroups : povray.general : Algorithm-approach to eliminate intersections... : Re: Algorithm-approach to eliminate intersections... Server Time
6 Aug 2024 08:15:23 EDT (-0400)
  Re: Algorithm-approach to eliminate intersections...  
From:
Date: 21 Jun 2002 08:21:14
Message: <1e66hu03rdtg9cvidfhlng6btsc7mutlh5@4ax.com>
On Fri, 21 Jun 2002 11:00:22 +0200, Tim Nikias <tim### [at] gmxde> wrote:
> I'm not sure what you mean with this... Preprocessing the heightfield and
> trying to predict, how many objects may be placed where, and
> then trying to place objects?

Since my language skills are limited take a look at below example.
Render this with 3.5.

#include "math.inc"
#include "functions.inc"

#default{texture{pigment{rgb 1}finish{ambient 1 diffuse 0}}}

#declare Count=1000;
#declare Generator=seed(0);

#declare Pattern=function{pattern{bozo}}
#declare Probability=function{Pattern(x,y,z)/10}

#local Min=<-1,-1,0>;
#local Max=<1,1,1>;

union{
#local C=0;
#while(C<Count)
  #local X=Interpolate(rand(Generator),0,1,Min.x,Max.x,1);
  #local Y=Interpolate(rand(Generator),0,1,Min.y,Max.y,1);
  #local Radius=Probability(X,Y,0);
  #if (!C) // first placing
    #declare Placing=function(x,y){f_sphere(x-X,y-Y,0,Radius)};
    #declare Distance=function(x,y){f_r(x-X,y-Y,0)};
    #declare C=C+1;
  #else
    #if(Placing(X,Y)>0)
      #if(Distance(X,Y)>Radius)
        sphere{<X,Y,0>.01}
        #declare t_Placing=function(x,y)
          {select(f_sphere(x-X,y-Y,0,Radius),-1,Placing(x,y))};
        #declare t_Distance=function(x,y)
          {min(Distance(x,y),f_r(x-X,y-Y,0))};
        #undef Placing
        #undef Distance
        #declare Placing=t_Placing;
        #declare Distance=t_Distance;
        #undef t_Placing
        #undef t_Distance
        #declare C=C+1;
      #end
    #end
  #end
#end
  box{
    Min Max
    pigment{function{1-Pattern(x,y,0)}}
  }
  translate 2.2*z
}

ABX


Post a reply to this message

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