[remove_colinear_vertices / Path] add preserve_uturns and use it for paths
This commit is contained in:
parent
495babf837
commit
ea93a7ef37
3 changed files with 56 additions and 19 deletions
|
|
@ -29,14 +29,19 @@ def test_remove_colinear_vertices() -> None:
|
|||
def test_remove_colinear_vertices_exhaustive() -> None:
|
||||
# U-turn
|
||||
v = [[0, 0], [10, 0], [0, 0]]
|
||||
v_clean = remove_colinear_vertices(v, closed_path=False)
|
||||
v_clean = remove_colinear_vertices(v, closed_path=False, preserve_uturns=True)
|
||||
# Open path should keep ends. [10,0] is between [0,0] and [0,0]?
|
||||
# Yes, they are all on the same line.
|
||||
assert len(v_clean) == 2
|
||||
# They are colinear, but it's a 180 degree turn.
|
||||
# We preserve 180 degree turns if preserve_uturns is True.
|
||||
assert len(v_clean) == 3
|
||||
|
||||
v_collapsed = remove_colinear_vertices(v, closed_path=False, preserve_uturns=False)
|
||||
# If not preserving u-turns, it should collapse to just the endpoints
|
||||
assert len(v_collapsed) == 2
|
||||
|
||||
# 180 degree U-turn in closed path
|
||||
v = [[0, 0], [10, 0], [5, 0]]
|
||||
v_clean = remove_colinear_vertices(v, closed_path=True)
|
||||
v_clean = remove_colinear_vertices(v, closed_path=True, preserve_uturns=False)
|
||||
assert len(v_clean) == 2
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue