Skip to content

Commit 9675b9c

Browse files
authored
Merge pull request #1352 from compas-dev/bugfix/bbox
Bugfix/bbox
2 parents 835f233 + 61d77b2 commit 9675b9c

File tree

4 files changed

+184183
-2
lines changed

4 files changed

+184183
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3737
* Changed imports of itertools to `compas.itertools` instead of `compas.utilities`.
3838
* Updated `compas_rhino.conversions.point_to_compas` to allow for `Rhino.Geometry.Point` as input.
3939
* Changed `compas.datastructures.Tree.print_hierarchy` to `compas.datastructures.Tree.__str__`.
40+
* Fixed `compas.geometry.bbox_numpy.minimum_volume_box` to avoid `numpy.linalg.LinAlgError`.
4041

4142
### Removed
4243

src/compas/geometry/bbox_numpy.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from compas.geometry import local_to_world_coordinates_numpy
1515
from compas.geometry import pca_numpy
1616
from compas.geometry import world_to_local_coordinates_numpy
17+
from compas.geometry import length_vector
1718
from compas.tolerance import TOL
1819

1920
from .bbox import bounding_box
@@ -73,7 +74,7 @@ def oriented_bounding_box_numpy(points, tol=None):
7374
>>> a = length_vector(subtract_vectors(bbox[1], bbox[0]))
7475
>>> b = length_vector(subtract_vectors(bbox[3], bbox[0]))
7576
>>> c = length_vector(subtract_vectors(bbox[4], bbox[0]))
76-
>>> close(a * b * c, 30.)
77+
>>> close(a * b * c, 30.0)
7778
True
7879
7980
"""
@@ -198,6 +199,8 @@ def minimum_volume_box(points, return_size=False):
198199
for simplex in hull.simplices:
199200
a, b, c = points[simplex]
200201
uvw = local_axes(a, b, c)
202+
if not length_vector(uvw[0]) or not length_vector(uvw[1]):
203+
continue
201204
frame = [a, uvw[0], uvw[1]]
202205
rst = world_to_local_coordinates_numpy(frame, xyz)
203206
rmin, smin, tmin = amin(rst, axis=0)

0 commit comments

Comments
 (0)