From f40608c0dcdb1ea5c18a6500c0d5b32e14490fe2 Mon Sep 17 00:00:00 2001 From: Romana Rust Date: Tue, 7 May 2024 19:09:32 +0200 Subject: [PATCH] updates --- CHANGELOG.md | 2 +- src/compas/geometry/bbox_numpy.py | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f12c17925367..c7c4973cec60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,7 +37,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Changed imports of itertools to `compas.itertools` instead of `compas.utilities`. * Updated `compas_rhino.conversions.point_to_compas` to allow for `Rhino.Geometry.Point` as input. * Changed `compas.datastructures.Tree.print_hierarchy` to `compas.datastructures.Tree.__str__`. -* Fixed `compas.geometry.bbox_numpy.minimum_volume_box` to ignore `numpy.linalg.LinAlgError`. +* Fixed `compas.geometry.bbox_numpy.minimum_volume_box` to avoid `numpy.linalg.LinAlgError`. ### Removed diff --git a/src/compas/geometry/bbox_numpy.py b/src/compas/geometry/bbox_numpy.py index d70e20947b42..30b79c43353c 100644 --- a/src/compas/geometry/bbox_numpy.py +++ b/src/compas/geometry/bbox_numpy.py @@ -8,13 +8,13 @@ from numpy import sum from numpy import vstack from numpy import zeros -from numpy.linalg import LinAlgError from scipy.spatial import ConvexHull from compas.geometry import local_axes from compas.geometry import local_to_world_coordinates_numpy from compas.geometry import pca_numpy from compas.geometry import world_to_local_coordinates_numpy +from compas.geometry import length_vector from compas.tolerance import TOL from .bbox import bounding_box @@ -199,11 +199,10 @@ def minimum_volume_box(points, return_size=False): for simplex in hull.simplices: a, b, c = points[simplex] uvw = local_axes(a, b, c) - frame = [a, uvw[0], uvw[1]] - try: - rst = world_to_local_coordinates_numpy(frame, xyz) - except LinAlgError: + if not length_vector(uvw[0]) or not length_vector(uvw[1]): continue + frame = [a, uvw[0], uvw[1]] + rst = world_to_local_coordinates_numpy(frame, xyz) rmin, smin, tmin = amin(rst, axis=0) rmax, smax, tmax = amax(rst, axis=0) dr = rmax - rmin