File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -466,8 +466,17 @@ def overlaps(self, other):
466466 """
467467 Returns whether this bounding box overlaps with the other bounding box.
468468 """
469- return (self .xmin <= other .xmax and other .xmin <= self .xmax
470- and self .ymin <= other .ymax and other .ymin <= self .ymax )
469+ ax1 , ay1 , ax2 , ay2 = self .extents
470+ bx1 , by1 , bx2 , by2 = other .extents
471+ if ax2 < ax1 :
472+ ax2 , ax1 = ax1 , ax2
473+ if ay2 < ay1 :
474+ ay2 , ay1 = ay1 , ay2
475+ if bx2 < bx1 :
476+ bx2 , bx1 = bx1 , bx2
477+ if by2 < by1 :
478+ by2 , by1 = by1 , by2
479+ return ax1 <= bx2 and bx1 <= ax2 and ay1 <= by2 and by1 <= ay2
471480
472481 def fully_containsx (self , x ):
473482 """
@@ -494,8 +503,17 @@ def fully_overlaps(self, other):
494503 Returns whether this bounding box overlaps with the other bounding box,
495504 not including the edges.
496505 """
497- return (self .xmin < other .xmax and other .xmin < self .xmax
498- and self .ymin < other .ymax and other .ymin < self .ymax )
506+ ax1 , ay1 , ax2 , ay2 = self .extents
507+ bx1 , by1 , bx2 , by2 = other .extents
508+ if ax2 < ax1 :
509+ ax2 , ax1 = ax1 , ax2
510+ if ay2 < ay1 :
511+ ay2 , ay1 = ay1 , ay2
512+ if bx2 < bx1 :
513+ bx2 , bx1 = bx1 , bx2
514+ if by2 < by1 :
515+ by2 , by1 = by1 , by2
516+ return ax1 < bx2 and bx1 < ax2 and ay1 < by2 and by1 < ay2
499517
500518 def transformed (self , transform ):
501519 """
You can’t perform that action at this time.
0 commit comments