Supposing the polygon descriptions obtained from M::G::Voronoi doesn't return different overlapping edges (that I think it doesn't):
  1. select all the points/polygons you want to merge: @points
  2. calculate the set of all the edges involved: @edges
  3. discard from @edges all the edges that have both side points belonging to @points
  4. reconstruct polygons from the remaining edges:
    1. calculate the set of all the vertices in @edges: @vertices
    2. set @polygon = (); $direction = vector (0, -1)
    3. get the leftmost $vertex from @vertices
    4. select from @edges the ones that have $vertex at some extreme: @departing
    5. for my $dep (@departing) { calculate the angle in the range (-π,π) between $direction and the vector ($dep->the_other_vertex - $vertex) } and select the edge $this_edge with minimum angle (minimum = most negative, not minimum in abs value!)
    6. push $polygon, $this_edge
    7. set $direction = previously calculated vector ($this_edge->the_other_vertex - $vertex)
    8. set $vertex = $this_edge->the_other_vertex
    9. repeat from 4.4 until $vertex is equal again to the starting vertex found in 4.3
    10. look for holes inside @polygon (left as an exercise for the reader :-) )
    11. remove the edges inside @polygon from @edges
    12. repeat from 4.1 until @edges is empty.

In reply to Re: Better maps with Math::Geometry::Voronoi, and a Challenge for Math Monks by salva
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.