Skip to content

Commit

Permalink
fix cut_poly_line ignoring last edge of polygon
Browse files Browse the repository at this point in the history
  • Loading branch information
podd0 committed Nov 1, 2023
1 parent 28fc8c9 commit a3230de
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion source/polygon.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ vector<Point<ld>> cut_poly(Point<ld> A, Point<ld> B, const vector<Point<ld>> &Q)
int n = ssize(Q);
for (int i = 0; i < n; i++) {
ld left1 = (B-A).cross(Q[i] - A), left2 = 0;
if (i != n-1) left2 = (B-A).cross(Q[(i+1)%n] - A);
left2 = (B-A).cross(Q[(i+1)%n] - A);
if (left1 > -EPS) P.push_back(Q[i%n]);
if (left1*left2 < -EPS)
P.push_back(intersec_line_seg(Q[i], Q[(i+1)%n], A, B));
Expand Down

0 comments on commit a3230de

Please sign in to comment.