File tree Expand file tree Collapse file tree 1 file changed +22
-4
lines changed Expand file tree Collapse file tree 1 file changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -466,8 +466,17 @@ def overlaps(self, other):
466
466
"""
467
467
Returns whether this bounding box overlaps with the other bounding box.
468
468
"""
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
471
480
472
481
def fully_containsx (self , x ):
473
482
"""
@@ -494,8 +503,17 @@ def fully_overlaps(self, other):
494
503
Returns whether this bounding box overlaps with the other bounding box,
495
504
not including the edges.
496
505
"""
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
499
517
500
518
def transformed (self , transform ):
501
519
"""
You can’t perform that action at this time.
0 commit comments