File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed
src/compas/geometry/shapes Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change 44
55from compas .geometry import Frame
66from compas .geometry import Line
7+ from compas .geometry import Point # noqa: F401
78from compas .geometry import Transformation
89from compas .geometry import Vector
910from 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
Original file line number Diff line number Diff line change 11import pytest
22import os
33import compas
4+ from random import random
45from compas .tolerance import TOL
6+ from compas .geometry import Box
57from compas .geometry import bounding_box
68from 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 ])
You can’t perform that action at this time.
0 commit comments