@@ -2321,15 +2321,27 @@ def common_axes(polygons, direction, min_distance, merge_distance, angle_toleran
2321
2321
if dist <= merge_distance :
2322
2322
dists .append (dist )
2323
2323
m_vecs .append (pt - close_pt )
2324
- if filter_tolerance > 0 : # evaluate whether axis is already aligned
2325
- if max (dists ) - min (dists ) <= filter_tolerance :
2326
- continue # axis is already aligned
2327
2324
sort_vecs = [v for _ , v in sorted (zip (dists , m_vecs ),
2328
2325
key = lambda pair : pair [0 ])]
2329
2326
m_vec = sort_vecs [0 ]
2330
2327
common_axes .append (com_ax .move (m_vec ))
2331
2328
axis_values .append (ax_val )
2332
2329
2330
+ # filter out axes that are already aligned
2331
+ if filter_tolerance > 0 : # evaluate whether axis is already aligned
2332
+ final_axes , final_values = [], []
2333
+ for com_ax , ax_val in zip (common_axes , axis_values ):
2334
+ dists = []
2335
+ for pt in mid_pts :
2336
+ close_pt = closest_point2d_on_line2d_infinite (pt , com_ax )
2337
+ dist = close_pt .distance_to_point (pt )
2338
+ if dist <= merge_distance :
2339
+ dists .append (dist )
2340
+ if max (dists ) - min (dists ) > filter_tolerance :
2341
+ final_axes .append (com_ax )
2342
+ final_values .append (ax_val )
2343
+ common_axes , axis_values = final_axes , final_values
2344
+
2333
2345
return common_axes , axis_values
2334
2346
2335
2347
@staticmethod
0 commit comments