Skip to content

Commit

Permalink
Conservative clipping for parallel case
Browse files Browse the repository at this point in the history
When clipping edge and polygon edge is parallel and overlapping,
`is_inside()` and `edge_intersection()` gives non-consistant results. In
such cases, conservatively preserve the polygon vertex for clipping.
  • Loading branch information
kkkkkom committed Jun 24, 2024
1 parent d19ca9e commit f08ebb9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ezdxf/math/clipping.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ def edge_intersection() -> Vec2:
# next polygon edge to test: edge_start -> edge_end
if is_inside(edge_end):
if not is_inside(edge_start):
clipped.append(edge_intersection())
clipped.append(edge_intersection() or edge_start)
clipped.append(edge_end)
elif is_inside(edge_start):
clipped.append(edge_intersection())
clipped.append(edge_intersection() or edge_end)
edge_start = edge_end
clip_start = clip_end
return (clipped,)
Expand Down

0 comments on commit f08ebb9

Please sign in to comment.