compas-dev / compas-dev/compas

LinAlgError on oriented_bounding_box_numpy with some inputs

Open
#1,127 2 comments 0 reactions 1 assignee Claimed by @tomvanmele View on GitHub
bug
Dominant language
Python
Stars
386
Forks
122
Avg merge
11d 46m
Merged PRs (30d)
1

Description

There are some valid inputs that cause `oriented_bounding_box_numpy` to throw an `numpy.linalg.LinAlgError`

**To Reproduce**
```python
import numpy as np

from compas.geometry import oriented_bounding_box_numpy

oriented_bounding_box_numpy(np.array([
[198.71435547, -18.45817566, 61.03982544],
[198.78266907, -18.38731384, 62.90990448],
[198.78266907, -18.38731384, 61.03982544],
[199.78454590, -17.34801292, 62.90990448],
[199.26994324, -17.88183594, 75.31147766],
[199.78454590, -17.34801292, 64.32066345],
[199.78454590, -17.34801292, 62.90989685],
]))
```
**Output**
```python
Traceback (most recent call last):
File "C:\Users\benel\AppData\Roaming\JetBrains\PyCharm2022.3\scratches\scratch.py", line 8, in
oriented_bounding_box_numpy(np.array([
File "C:\git\buildots\pycode\venv39\lib\site-packages\compas\geometry\bbox\bbox_numpy.py", line 133, in oriented_bounding_box_numpy
rst = world_to_local_coordinates_numpy(frame, xyz)
File "C:\git\buildots\pycode\venv39\lib\site-packages\compas\geometry\transformations\transformations_numpy.py", line 141, in world_to_local_coordinates_numpy
rst = solve(uvw, xyz)
File "C:\git\buildots\pycode\venv39\lib\site-packages\scipy\linalg\_basic.py", line 223, in solve
_solve_check(n, info)
File "C:\git\buildots\pycode\venv39\lib\site-packages\scipy\linalg\_basic.py", line 29, in _solve_check
raise LinAlgError('Matrix is singular.')
numpy.linalg.LinAlgError: Matrix is singular.
```
**Expected behavior**
Getting an oriented bounding box of this specific set of points

**Desktop:**
- OS: Windows11 - 64bit
- Python version 3.9.10
- Numpy version 1.23.5
- Scipy version 1.10.0
- Python package manager: pip

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.