POV-Ray : Newsgroups : povray.text.scene-files : Voronoi cell polygon macro : Re: Voronoi cell polygon macro Server Time
28 Mar 2024 12:29:36 EDT (-0400)
  Re: Voronoi cell polygon macro  
From: Bill Pragnell
Date: 24 Nov 2022 19:35:00
Message: <web.63800c97102ee226b96893c06f35e431@news.povray.org>
Example usage:

#declare Sd = seed(0);
#declare N = 250;
#declare Points = array[N];
#for (I, 0, N-1)
 #declare Points[I] = <rand(Sd)*20-10, 0, rand(Sd)*20-10>;
#end

#declare Cells = array[1];
VoronoiCells(Points, Cells)

#for (I, 0, N-1)
 #declare NC = dimension_size(Cells[I], 1);
 #if (NC > 2)
  prism {
   0, rand(Sd)*4 + 1,
   NC+1,
   #for (J, 0, NC-1)
    <Cells[I][J].x, Cells[I][J].z>,
   #end
   <Cells[I][0].x, Cells[I][0].z>
   pigment { rgb <rand(Sd)*0.5+0.5, rand(Sd)*0.5+0.5, rand(Sd)*0.5+0.5> }
   finish { ambient 0 }
  }
 #end
#end


Post a reply to this message

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