Skip to content

Commit 61ae095

Browse files
committed
add test for flat box
1 parent 40b0e2e commit 61ae095

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

src/compas/geometry/shapes/box.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from compas.geometry import Frame
66
from compas.geometry import Line
7+
from compas.geometry import Point # noqa: F401
78
from compas.geometry import Transformation
89
from compas.geometry import Vector
910
from compas.geometry import centroid_points
@@ -478,7 +479,7 @@ def from_points(cls, points): # type: (...) -> Box
478479
# Discretisation
479480
# ==========================================================================
480481

481-
def compute_vertices(self): # type: () -> list[list[float]]
482+
def compute_vertices(self): # type: () -> list[Point]
482483
"""Compute the vertices of the discrete representation of the box."""
483484
point = self.frame.point
484485
xaxis = self.frame.xaxis

tests/compas/geometry/test_bbox.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import pytest
22
import os
33
import compas
4+
from random import random
45
from compas.tolerance import TOL
6+
from compas.geometry import Box
57
from compas.geometry import bounding_box
68
from compas.geometry import bounding_box_xy
79

@@ -146,3 +148,26 @@ def test_oriented_bounding_box_numpy_from_fixtures():
146148
results = oriented_bounding_box_numpy(coords)
147149
for result, expected_values in zip(results, expected):
148150
assert TOL.is_allclose(result, expected_values)
151+
152+
153+
def test_oriented_bounding_box_numpy_flat():
154+
if compas.IPY:
155+
return
156+
157+
from compas.geometry import oriented_bounding_box_numpy
158+
159+
points = [[10 * random(), 10 * random(), 0] for i in range(100)]
160+
box = Box.from_bounding_box(oriented_bounding_box_numpy(points))
161+
162+
for point in points:
163+
assert box.contains_point(point)
164+
165+
assert not box.contains_point([10 * random(), 10 * random(), 1])
166+
167+
points = [[10 * random(), 10 * random(), 10] for i in range(100)]
168+
box = Box.from_bounding_box(oriented_bounding_box_numpy(points))
169+
170+
for point in points:
171+
assert box.contains_point(point)
172+
173+
assert not box.contains_point([10 * random(), 10 * random(), 11])

0 commit comments

Comments
 (0)