33import compas
44from random import random
55from compas .tolerance import TOL
6+ from compas .datastructures import Mesh
67from compas .geometry import Box
78from compas .geometry import bounding_box
89from compas .geometry import bounding_box_xy
@@ -177,17 +178,14 @@ def test_minimum_area_rectangle_xy():
177178 if compas .IPY :
178179 return
179180
180- from compas .datastructures import Mesh
181181 from compas .geometry import bbox_numpy
182182 import numpy as np
183183
184- bad_mesh = Mesh .from_obj (os .path .join (HERE , "fixtures" , "bbox_rect_bad.obj" ))
185- compas_pts , _ = bad_mesh .to_vertices_and_faces ()
186- points = np .array (compas_pts )
187-
184+ mesh = Mesh .from_obj (os .path .join (HERE , "fixtures" , "bbox_rect_bad.obj" ))
185+ points , _ = mesh .to_vertices_and_faces ()
188186 expected = [[359.481028 , 229.73229169 ], [256.84043629 , 120.92493596 ], [295.67358196 , 84.29269706 ], [398.31417367 , 193.10005279 ]]
189187
190- min_bbox = bbox_numpy .minimum_area_rectangle_xy (points )
188+ min_bbox = bbox_numpy .minimum_area_rectangle_xy (np . array ( points ) )
191189
192190 assert TOL .is_allclose ([(x , y ) for x , y in min_bbox ], expected )
193191
@@ -196,16 +194,13 @@ def test_minimum_area_rectangle_xy_translated():
196194 if compas .IPY :
197195 return
198196
199- from compas .datastructures import Mesh
200197 from compas .geometry import bbox_numpy
201198 import numpy as np
202199
203- bad_mesh = Mesh .from_obj (os .path .join (HERE , "fixtures" , "bbox_rect_good.obj" ))
204- compas_pts , _ = bad_mesh .to_vertices_and_faces ()
205- points = np .array (compas_pts )
206-
200+ mesh = Mesh .from_obj (os .path .join (HERE , "fixtures" , "bbox_rect_good.obj" ))
201+ points , _ = mesh .to_vertices_and_faces ()
207202 expected = [[307.39472429 , 358.36965131 ], [204.75412877 , 249.56229154 ], [243.58728967 , 212.93003827 ], [346.22788519 , 321.73739804 ]]
208203
209- min_bbox = bbox_numpy .minimum_area_rectangle_xy (points )
204+ min_bbox = bbox_numpy .minimum_area_rectangle_xy (np . array ( points ) )
210205
211206 assert TOL .is_allclose ([(x , y ) for x , y in min_bbox ], expected )
0 commit comments