Skip to content

Commit fedf86e

Browse files
authored
Merge pull request #1426 from compas-dev/rectangle_xy
Rectangle xy
2 parents 5896f35 + 4f62bdf commit fedf86e

File tree

5 files changed

+1827
-4
lines changed

5 files changed

+1827
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313

1414
### Changed
1515

16+
* Fixed unexpected behavior in `compas.geometry.bbox_numpy.minimum_area_rectangle_xy`.
1617
* Changed `requirements.txt` to allow `numpy>=2`.
1718
* Fixed bug in `compas.geometry.Polygon.points` setter by removing duplicate points if they exist.
1819
* Fixed bug in `compas.geometry.Polygon.plane` by aligning the normal of the bestfit plane with the approximate normal of the polygon faces.
19-
* Changed the order of face vertices in `compas.geometry.Surface.to_vertices_and_faces` to a counter clockwise cycling direction and outward facing normals for curved surfaces.
20+
* Changed the order of face vertices in `compas.geometry.Surface.to_vertices_and_faces` to a counter clockwise cycling direction and outward facing normals for curved surfaces.>>>>>>> main
2021

2122
### Removed
2223

src/compas/geometry/bbox_numpy.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,11 +250,10 @@ def minimum_area_rectangle_xy(points, return_size=False):
250250
"""
251251
boxes = []
252252

253-
n = len(points)
254253
points = points[:, :2]
255254
hull = ConvexHull(points)
256255
xy = points[hull.vertices, :2]
257-
mean = sum(xy, axis=0) / n
256+
hull_centroid = sum(xy, axis=0) / len(xy)
258257

259258
for simplex in hull.simplices:
260259
p0 = points[simplex[0]]
@@ -288,7 +287,7 @@ def minimum_area_rectangle_xy(points, return_size=False):
288287
a = w * h
289288

290289
# other box corners
291-
if dot(t, mean - p0) < 0:
290+
if dot(t, hull_centroid - p0) < 0:
292291
b3 = b0 - h * tu
293292
b2 = b1 - h * tu
294293
else:

0 commit comments

Comments
 (0)