POV-Ray : Newsgroups : povray.general : The Voronoi function and POVray pigments : The Voronoi function and POVray pigments Server Time
6 Aug 2024 10:24:33 EDT (-0400)
  The Voronoi function and POVray pigments  
From: Sir Charles W  Shults III
Date: 27 Mar 2002 04:49:29
Message: <3ca195a9$1@news.povray.org>
I just finished doing a little web research on the Voronoi function because
it seems to be so flexible and powerful for creating "pseudo-random" patterns.
What a fascinating bit a reading!  I suppose that anyone who uses POVray and
reads the documentation has come across the term in the description of how the
patterns are derived.  It was enough to get me to read up on the function and
how it works.
    The description went through Delaunay methods of dividing up a set of points
into triangles based on the closest natural neighbors, and how that leads to the
Voronoi function.    In brief, imagine that you have a set of random (or nearly
so) points on a sheet of paper.  Each point has neighbors, and you can evaluate
them to see which three are closest to some arbitrary starting point, then
create a line to each from your original point.  That is basically the DeLaunay
method of tesselating the plane into triangles.
    Well, Voronoi is similar in that you create a polygon around each point that
contains all the points that are closer to that point than to any other point.
In other words, you fence in the area that is closer to your point.  This can be
done using the DeLaunay method.
    What you end up with is something that looks like the crackle pattern- throw
some random points on a plane, set a boundary condition mathematically, and draw
the polygons.  As the POVray documents state, all the patterns like crackle and
bozo are really one and the same, but you can see that the scale of the data is
different, resulting in sharper or more diffuse boundaries.  Add functions like
turbulence and lambda and you can make rocks, clouds, etc.
    If you extend the idea to 3 dimensional space, you end up with space filling
"polytopes" instead of flat polygons.  All you need is a volume with a
scattering of random points through it and a tesselating algorithm.
    Voronoi diagrams are sometimes called "Dirichlet tesselations"- maybe I have
just rambled on enough, but it seems like a fascinating subject to me.  I guess
it has been brought on it part by the fact that I am playing with patterns and
isosurfaces and functions.  Seeing the methods just makes it all more concrete
for me.
    I may have made some mistakes in my understanding or explanations, but I
hope the POV gods will forgive them due to my enthusiasm.  As a peace offering,
here is a rather outrageous function and color map based on simple trig.  Enjoy
it and wrap it around a few things, and be sure to play with the scale and
translation!

#declare G = pigment { function{tan(x*y*z)} };

#declare TanBow = texture {
  pigment {G
    color_map {
      [0.00 Red]
      [0.33 Green]
      [0.66 Blue]
      [1.00 Red]
    }
} }

Cheers!

Chip Shults
My robotics, space and CGI web page - http://home.cfl.rr.com/aichip

light_source{0#macro k(_)sphere{13*z+i*_.5pigment{agate}finish{phong.3}}#end
1}#macro _(s,i,g)#if(s)k(1)k(-1)_(s-1i+g,g)#end#end _(3x+3*y<2,-2>)_(2x,y)_(
2x-y,x)_(4x*3,-y)_(4<3,1>x)_(2x*6,-y)


Post a reply to this message

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