def polygonsOverlap(poly1, poly2):
 try:
  poly1 = poly1.verticesPix
 except Exception:
  pass
 try:
  poly2 = poly2.verticesPix
 except Exception:
  pass
 if haveMatplotlib:
  if (matplotlib.__version__ > '1.2'):
   if any(mplPath(poly1).contains_points(poly2)):
    return True
   return any(mplPath(poly2).contains_points(poly1))
  else:
   try:
    if any(nxutils.points_inside_poly(poly1, poly2)):
     return True
    return any(nxutils.points_inside_poly(poly2, poly1))
   except Exception:
    pass
 for p1 in poly1:
  if pointInPolygon(p1[0], p1[1], poly2):
   return True
 for p2 in poly2:
  if pointInPolygon(p2[0], p2[1], poly1):
   return True
 return False

def polygonsOverlap ( poly1 , poly2 ) : try : poly1 = poly1 . verticesPix except Exception : pass try : poly2 = poly2 . verticesPix except Exception : pass if haveMatplotlib : if ( matplotlib . __version__ > '1.2' ) : if any ( mplPath ( poly1 ) . contains_points ( poly2 ) ) : return True return any ( mplPath ( poly2 ) . contains_points ( poly1 ) ) else : try : if any ( nxutils . points_inside_poly ( poly1 , poly2 ) ) : return True return any ( nxutils . points_inside_poly ( poly2 , poly1 ) ) except Exception : pass for p1 in poly1 : if pointInPolygon ( p1 [ 0 ] , p1 [ 1 ] , poly2 ) : return True for p2 in poly2 : if pointInPolygon ( p2 [ 0 ] , p2 [ 1 ] , poly1 ) : return True return False
determine if two polygons intersect; can fail for very pointy polygons .