in reply to Merging Polygons

Yes, but it's not that simple. What if two lines are equivalent, but one is shorter than the other? What if merging two polygons creates an internal "hole"? This could be quite an interesting thing to program.

Replies are listed 'Best First'.
Re^2: Merging Polygons
by thekestrel (Friar) on Mar 30, 2005 at 14:47 UTC
    TedPride
    The example I gave would work if the equivalent lines were different lengths with slight modification. Identifiy the points that are on the same line, only add points from second line if they are not the same as the first. If you look at the post gnu@perl did for an example we have two shapes A-B-C-D and E-F-G-H. in this case B-C is on the same line as H-E and H-E is shorter. Thus on the co-linear line looking down it you would have B-H-E-C. From my routine you would insert the H-E shape between points B-C. Thus going from
    A-B-C-D and E-F-G-H to A-(B-C)-D and E)-F-G-(H which gives A-B-E-F-G-H-C-D or A----B | | | | E-----F | | | | | | H-----G D----C A----B | | | E-----F | | | H-----G D----C
    You are right though this does not take care of holes, or overlaps and intersections, this would be more a pure math problem of intersections etc and these can be found on the web. I was just postulating that the problem may have been more one of tiling and hence if this was the case the solution is not all that complicated.

    Regards Paul.

    Update: There is a good link here which can be simplified as some of the calculations are already available in the module Math::Geometry::Planar from my first post.