perlmeditation
samtregar
Monks! Want to see some pretty colors? Check out a demo of my new module, [cpan://Math::Geometry::Voronoi]:
<p>
<blockquote><a href="http://sam.tregar.com/voronoi.cgi">http://sam.tregar.com/voronoi.cgi</a></blockquote>
<p>
I'm using this at my day job to make overlays for Google maps. So far it's been pretty great - producing very natural looking maps. (If that link is slow or broken try again in a bit - it's a CGI on a shared server with fairly low limits.)
<p>
Want to help me make it better? I tried (and failed) to write code to join polygons when mapping multiple points in a set. In a Voronoi diagram each point generates a polygon. If I color all the polygons from a set the same color I get a map that looks right, but the code would run a lot faster if I could draw just a few bigger polygons instead of hundreds of little ones.
<p>
The code I wrote (which I never released because it didn't work) walked through the set of polygons looking for common edges, combining polygons along each edge. That worked fine in early rounds, joining big polygons with small ones. The problem is that after a while you'll reach a case where a polygon needs to be joined with itself - that is, it has an internal edge. I couldn't find a way to reliably remove the internal edges (which may be long strings of multiple edges) without sometimes botching the job and killing the polygon.
<p>
Another useful note - the input polygons produced by voronoi mapping are convex, but the output usually won't be. So just computing the convex hull won't work.
<p>
Mathmonks, I call on you! The first one to turn in a working implementation gets to be a co-maintainer of the module on CPAN. Think of the glory! And the recriminations when the code doesn't compile on an ancient AIX machine! Forget that last one!
<p>
-sam