[remove_colinear_vertices] keep two vertices if all were colinear

This commit is contained in:
Jan Petykiewicz 2026-02-14 19:15:54 -08:00
commit 05098c0c13

View file

@ -51,6 +51,10 @@ def remove_colinear_vertices(vertices: ArrayLike, closed_path: bool = True) -> N
if not closed_path:
slopes_equal[[0, -1]] = False
if slopes_equal.all() and vertices.shape[0] > 0:
# All colinear, keep the first and last
return vertices[[0, vertices.shape[0] - 1]]
return vertices[~slopes_equal]