Skip to content

Commit 0adfe18

Browse files
committed
fix(polygon): Minor improvement to ensure helpful axes are not filtered
1 parent d9eae33 commit 0adfe18

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

ladybug_geometry/geometry2d/polygon.py

+15-3
Original file line numberDiff line numberDiff line change
@@ -2321,15 +2321,27 @@ def common_axes(polygons, direction, min_distance, merge_distance, angle_toleran
23212321
if dist <= merge_distance:
23222322
dists.append(dist)
23232323
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
23272324
sort_vecs = [v for _, v in sorted(zip(dists, m_vecs),
23282325
key=lambda pair: pair[0])]
23292326
m_vec = sort_vecs[0]
23302327
common_axes.append(com_ax.move(m_vec))
23312328
axis_values.append(ax_val)
23322329

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+
23332345
return common_axes, axis_values
23342346

23352347
@staticmethod

0 commit comments

Comments
 (0)