Assuming you're wanting to join two polygons that both share a common line i.e. two subsequent vertices of exactly the same points and not worry about intersecting polygons it would not be that hard to do.
A bit or pseudo-code on my thoughts...

# assuming polygon is 1-2-3-(4=1 implied) for a square #Get both shapes going in the same direction # to make things simpler later Order array of shape 1 so that its a clockwise closed shape Order array of shape 2 so that its a clockwise closed shape foreach line in shape 1 { foreach line in shape 2 { are line1 and line two the same { store which line this is. } } } splice into array of shape1 at point of common line all of shape 2 rem +oving the common line.

Regards Paul

In reply to Re: Merging Polygons by thekestrel
in thread Merging Polygons by Anonymous Monk

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.