Fix intersection for boxes on boundary

This commit is contained in:
Adam J. Stewart 2021-07-16 20:19:36 +00:00
Родитель 7e8fd461d8
Коммит 53fb4b28b9
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: C66C0675661156FC
2 изменённых файлов: 9 добавлений и 6 удалений

Просмотреть файл

@ -33,6 +33,9 @@ class TestBoundingBox:
@pytest.mark.parametrize(
"test_input,expected",
[
# Same box
((0, 1, 0, 1, 0, 1), True),
((0.0, 1.0, 0.0, 1.0, 0.0, 1.0), True),
# bbox1 strictly within bbox2
((-1, 2, -1, 2, -1, 2), True),
# bbox2 strictly within bbox1

Просмотреть файл

@ -102,12 +102,12 @@ class BoundingBox(Tuple[float, float, float, float, float, float]):
True if bounding boxes intersect, else False
"""
return (
self.minx < other.maxx
and self.maxx > other.minx
and self.miny < other.maxy
and self.maxy > other.miny
and self.mint < other.maxt
and self.maxt > other.mint
self.minx <= other.maxx
and self.maxx >= other.minx
and self.miny <= other.maxy
and self.maxy >= other.miny
and self.mint <= other.maxt
and self.maxt >= other.mint
)