Return the intersection of *bbox1* and *bbox2* if they intersect, or None if they don't.
(bbox1, bbox2)
| 675 | |
| 676 | @staticmethod |
| 677 | def intersection(bbox1, bbox2): |
| 678 | """ |
| 679 | Return the intersection of *bbox1* and *bbox2* if they intersect, or |
| 680 | None if they don't. |
| 681 | """ |
| 682 | x0 = np.maximum(bbox1.xmin, bbox2.xmin) |
| 683 | x1 = np.minimum(bbox1.xmax, bbox2.xmax) |
| 684 | y0 = np.maximum(bbox1.ymin, bbox2.ymin) |
| 685 | y1 = np.minimum(bbox1.ymax, bbox2.ymax) |
| 686 | return Bbox([[x0, y0], [x1, y1]]) if x0 <= x1 and y0 <= y1 else None |
| 687 | |
| 688 | |
| 689 | _default_minpos = np.array([np.inf, np.inf]) |
no test coverage detected