<div dir="ltr"><div><div><div><div>Hello Al,<br><br>The search terms you are looking for are 'polygon clipping' and 'boolean operations on polygons'.<br><br></div>Matplotlib can clip one polygon with respect to another, there is a simple example at <a href="http://stackoverflow.com/questions/22612323/clipping-a-triagle-with-a-circle-in-matplotlib">http://stackoverflow.com/questions/22612323/clipping-a-triagle-with-a-circle-in-matplotlib</a><br><br></div>Alternatively, for more flexibility use shapely.  For example:<br><br>    from shapely.geometry import Polygon<br>    a = Polygon([(0, 0), (1.1, 0), (1.1, 1.1), (0, 1.1)])<br>    b = Polygon([(.9, 0), (2, 0), (2, 1.1), (.9, 1.1)])<br>    c = Polygon([(.9, .9), (2, .9), (2, 2), (.9, 2)])<br></div>    d = a.intersection(b).intersection(c)<br></div>    print(d)<br><br>which outputs<br><br>POLYGON ((0.9 0.9, 0.9 1.1, 1.1 1.1, 1.1 0.9, 0.9 0.9))<br><br><div><div>i.e. a rectangle from x = 0.9 to 1.1 and y from 0.9 to 1.1.<br><br></div><div>Ian Thomas<br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 12 November 2015 at 03:47, Al Niessner <span dir="ltr"><<a href="mailto:Al.Niessner@gmx.net" target="_blank">Al.Niessner@gmx.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
I have three paths that each define a bounding box. Lets just say I have<br>
these three in (x,y) coordinates and all are moveto, lineto, lineto,<br>
lineto, and closepoly:<br>
<br>
1: (0, 0), (1.1, 0), (1.1, 1.1), (0, 1.1), (0, 0)<br>
2: (.9, 0), (2, 0), (2, 1.1), (.9, 1.1), (.9, 0)<br>
3: (.9, .9), (2, .9), (2, 2), (.9, 2) (.9, .9)<br>
<br>
While my paths have more nodes and are not as cleanly vertical and<br>
horizontal, it does cover the nature of what I am experiencing.<br>
<br>
The first thing to note is that each box has overlap at x = 1 and y = 1<br>
and all three boxes overlap at (1,1).<br>
<br>
What I am looking for is an optimizer that would be smart enough to say<br>
hey, because of the overlap, we can trim the boxes to:<br>
<br>
1: (0,0) (1,0) (1,1) (0,1) (0,0)<br>
2: (1,0) (2,0) (2,1), (1,1), (1,0)<br>
3: (1,1) (2,1) (2,2), (1,2), (1,1)<br>
<br>
I am not sure that optimizer is the right word to use either. I have<br>
poked around matplotlib a bit (over many years) and tried searching but<br>
guessing the search terms is not simple either. Hence, I am asking if<br>
anyone is aware of matplotlib functionality that will help me do this<br>
task. Any other tool outside of matplotlib would be just as nice of a<br>
suggestion. One last bit, it has to work for N paths.<br>
<br>
As always, thanks in advance.<br>
<br>
--<br>
Al Niessner<br>
<br>
I have never found the companion that was so companionable as solitude.<br>
- From Walden by Henry David Thoreau<br>
<br>
The universe is indifferent, and life is brutal; however, it is man's<br>
choice of behavior that makes them malevolent rather than benevolent.<br>
<br>
Some will fall in love with life and drink it from a fountain<br>
That is pouring like an avalanche coming down the mountain.<br>
- From the song Pepper by the Butthole Surfers<br>
<br>
<br>
_______________________________________________<br>
Matplotlib-users mailing list<br>
<a href="mailto:Matplotlib-users@python.org">Matplotlib-users@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/matplotlib-users" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/matplotlib-users</a><br>
</blockquote></div><br></div></div>