def test_do_not_intersect_or_overlap_empty(self): bbox = BoundingBox([(0, 0, 0), (3, 3, 3)]) empty = BoundingBox() assert bbox.has_intersection(empty) is False assert bbox.has_overlap(empty) is False assert empty.has_intersection(bbox) is False assert empty.has_overlap(bbox) is False assert empty.has_intersection(empty) is False assert empty.has_overlap(empty) is False
def test_touching_3d_boxes(self): bbox1 = BoundingBox([(0, 0, 0), (1, 1, 1)]) bbox2 = BoundingBox([(1, 1, 1), (2, 2, 2)]) bbox3 = BoundingBox([(-1, -1, -1), (0, 0, 0)]) assert bbox1.has_intersection(bbox2) is False assert bbox1.has_overlap(bbox2) is True assert bbox2.has_intersection(bbox1) is False assert bbox2.has_overlap(bbox1) is True assert bbox1.has_intersection(bbox3) is False assert bbox1.has_overlap(bbox3) is True assert bbox3.has_intersection(bbox1) is False assert bbox3.has_overlap(bbox1) is True
def points_in_bbox(self, bbox: BoundingBox) -> Iterator[AnyVec]: for child in self.children: if bbox.has_overlap(child.bbox): yield from child.points_in_bbox(bbox)
def test_has_overlap_accepts_2d_bounding_box(self): bbox1 = BoundingBox([(0, 0, 0), (10, 10, 10)]) bbox2 = BoundingBox2d([(1, 1), (9, 9)]) # z-axis are 0 assert bbox1.has_overlap(bbox2) is True
def test_crossing_3d_boxes(self): # bboxes do overlap, but do not contain corner points of the other bbox bbox1 = BoundingBox([(0, 1, 0), (3, 2, 1)]) bbox2 = BoundingBox([(1, 0, 0), (2, 3, 1)]) assert bbox1.has_intersection(bbox2) is True assert bbox1.has_overlap(bbox2) is True