One thing that may be confusing your attempts to join the polygons, is that the polygons returned from M::G::V->polygons can contain duplicate points. Are you aware of this?

By way of example, the following creates a regular grid of 9x7 equi-spaced points and the uses M::G::V to compute and return the polys. The result is 35 (7x5) "square" polygons. But each of the polys return has 6 rather than 4 points? With 2 points being duplicated in each poly. This doesn't affect the drawing of the polys, but it gets confusing when trying to manipulate the edges.

#! perl -slw use strict; use Data::Dump qw[ pp ]; $Data::Dump::MAX_WIDTH = 200; use Math::Geometry::Voronoi; my @points = map{ my $y = $_; map [ $_, $y ], map $_ * 100, 1 .. 9; } map $_ * 100, 1 .. 7; my $geo = Math::Geometry::Voronoi->new( points => \@points ); $geo->compute; my @geoPolys = $geo->polygons; pp \@geoPolys;

Produces:

C:\test>voronoi [ ## {**** duplicates ****} {**** duplicates ****} [10, [250, 250], [250, 250], [250, 150], [150, 150], [150, 150], [15 +0, 250]], [11, [350, 250], [350, 250], [350, 150], [250, 150], [250, 150], [25 +0, 250]], [12, [450, 250], [450, 250], [450, 150], [350, 150], [350, 150], [35 +0, 250]], [13, [550, 250], [550, 250], [550, 150], [450, 150], [450, 150], [45 +0, 250]], [14, [650, 250], [650, 250], [650, 150], [550, 150], [550, 150], [55 +0, 250]], [15, [750, 250], [750, 250], [750, 150], [650, 150], [650, 150], [65 +0, 250]], [16, [850, 250], [850, 250], [850, 150], [750, 150], [750, 150], [75 +0, 250]], [19, [250, 350], [250, 350], [250, 250], [150, 250], [150, 250], [15 +0, 350]], [20, [350, 350], [350, 350], [350, 250], [250, 250], [250, 250], [25 +0, 350]], [21, [450, 350], [450, 350], [450, 250], [350, 250], [350, 250], [35 +0, 350]], [22, [550, 350], [550, 350], [550, 250], [450, 250], [450, 250], [45 +0, 350]], [23, [650, 350], [650, 350], [650, 250], [550, 250], [550, 250], [55 +0, 350]], [24, [750, 350], [750, 350], [750, 250], [650, 250], [650, 250], [65 +0, 350]], [25, [850, 350], [850, 350], [850, 250], [750, 250], [750, 250], [75 +0, 350]], [28, [250, 450], [250, 450], [250, 350], [150, 350], [150, 350], [15 +0, 450]], [29, [350, 450], [350, 450], [350, 350], [250, 350], [250, 350], [25 +0, 450]], [30, [450, 450], [450, 450], [450, 350], [350, 350], [350, 350], [35 +0, 450]], [31, [550, 450], [550, 450], [550, 350], [450, 350], [450, 350], [45 +0, 450]], [32, [650, 450], [650, 450], [650, 350], [550, 350], [550, 350], [55 +0, 450]], [33, [750, 450], [750, 450], [750, 350], [650, 350], [650, 350], [65 +0, 450]], [34, [850, 450], [850, 450], [850, 350], [750, 350], [750, 350], [75 +0, 450]], [37, [250, 550], [250, 550], [250, 450], [150, 450], [150, 450], [15 +0, 550]], [38, [350, 550], [350, 550], [350, 450], [250, 450], [250, 450], [25 +0, 550]], [39, [450, 550], [450, 550], [450, 450], [350, 450], [350, 450], [35 +0, 550]], [40, [550, 550], [550, 550], [550, 450], [450, 450], [450, 450], [45 +0, 550]], [41, [650, 550], [650, 550], [650, 450], [550, 450], [550, 450], [55 +0, 550]], [42, [750, 550], [750, 550], [750, 450], [650, 450], [650, 450], [65 +0, 550]], [43, [850, 550], [850, 550], [850, 450], [750, 450], [750, 450], [75 +0, 550]], [46, [250, 650], [250, 650], [250, 550], [150, 550], [150, 550], [15 +0, 650]], [47, [350, 650], [350, 650], [350, 550], [250, 550], [250, 550], [25 +0, 650]], [48, [450, 650], [450, 650], [450, 550], [350, 550], [350, 550], [35 +0, 650]], [49, [550, 650], [550, 650], [550, 550], [450, 550], [450, 550], [45 +0, 650]], [50, [650, 650], [650, 650], [650, 550], [550, 550], [550, 550], [55 +0, 650]], [51, [750, 650], [750, 650], [750, 550], [650, 550], [650, 550], [65 +0, 650]], [52, [850, 650], [850, 650], [850, 550], [750, 550], [750, 550], [75 +0, 650]], ]

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

In reply to Re: Better maps with Math::Geometry::Voronoi, and a Challenge for Math Monks by BrowserUk
in thread Better maps with Math::Geometry::Voronoi, and a Challenge for Math Monks by samtregar

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.