Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re: Better maps with Math::Geometry::Voronoi, and a Challenge for Math Monksby roboticus (Chancellor) |
on Jul 02, 2008 at 15:02 UTC ( [id://695140]=note: print w/replies, xml ) | Need Help?? |
samtregar:
I've some ideas on how to add polygon creation to the code that actually creates the vertex / line / edge list, but I don't really have time to code it up at the moment. But if I had to do it in a separate routine, then here's what I'd do:
Note: This method uses integer comparisons only, so you needn't worry about float mismatches... Suppose, for example, you have:
Note: This is a hand-constructed dataset, which is definitely *not* a voronoi diagram. (I don't have the voronoi package installed on this machine. (In retrospect, it would've been faster for me to install & run it and build a *real* dataset... oh, well.) If points 0 and 3 are the same color, while the other two differ, then when you scan your edge list, you'll mark edge/line 3 as "removed", and edit the list to replace all references of point 3 with point 0, giving:
As I mentioned above, I was thinking I'd change the C code to create the polygons in the same process as computing the lines/edges/vertices. The method I was going to use was to add a column to @points for "match" determination. (I.e., your code would do the first step before constructing the diagram.) Then it would construct the vertices & edges normally, but during line construction perform the replacement on the fly. (You could have two pairs of point references, one as is computed currently and the other holding the "edited" point references, in case you wanted the original regions *and* the combined ones...) ...roboticus
In Section
Meditations
|
|