Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected behavior of "bbox_numpy.minimum_area_rectangle_xy" #1422

Open
dominikreisach opened this issue Jan 15, 2025 · 1 comment · May be fixed by #1426
Open

Unexpected behavior of "bbox_numpy.minimum_area_rectangle_xy" #1422

dominikreisach opened this issue Jan 15, 2025 · 1 comment · May be fixed by #1426
Assignees
Labels

Comments

@dominikreisach
Copy link

Describe the bug
Tried to compute a xy oriented minimum bounding box. Sometimes it works, sometimes the base rectangle appears to be mirrored.

To Reproduce
Steps to reproduce the behavior:

  1. Context: Rhino / Grasshopper
  2. Sample Python 3 script in GH
# requirements: compas==2.8.1
# requirements: numpy

from compas.datastructures import Mesh
from compas.geometry import bbox_numpy, Point
from compas.scene import Scene
import numpy as np

file_path = "..."

compas_mesh = Mesh.from_obj(file_path)

compas_pts, _ = compas_mesh.to_vertices_and_faces()

arr = np.array(compas_pts)

minimum_area_rect = bbox_numpy.minimum_area_rectangle_xy(arr)

pts = []

for pt in minimum_area_rect:
    pts.append(Point(pt[0], pt[1], 0.0))

scene = Scene()
scene.add(pts[0])
scene.add(pts[1])
scene.add(pts[2])
scene.add(pts[3])

a = scene.draw()
  1. See OBJ files: meshes.zip

Expected behavior

This:
image

Unexpected behavior

It seems like the minimum area rectangle is mirrored. The only change is moving the mesh on the canvas, with all coordinates remaining positive.
image

Expected goal

xy_ombb rotated to align with the coordinate system.
image

Desktop (please complete the following information):

  • OS: iOS
  • Python version == 3.12.8
  • COMPAS version == 2.8.1
  • Python package manager: conda / pip
@chenkasirer chenkasirer self-assigned this Jan 20, 2025
@chenkasirer chenkasirer linked a pull request Jan 20, 2025 that will close this issue
10 tasks
@chenkasirer
Copy link
Member

@dominikreisach thanks for reporting.
I think this might be a bug and believe I was able to find the cause. Opened a PR with a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants