8000 FIX: 0 length segment intersect · matplotlib/matplotlib@df6316c · GitHub
[go: up one dir, main page]

Skip to content

Commit df6316c

Browse files
committed
FIX: 0 length segment intersect
One method to fix #15842 In this case we check that if either segment is 0 length, it intersects with no other segments, not all other segments.
1 parent ffa84e0 commit df6316c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/_path.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,13 @@ inline bool segments_intersect(const double &x1,
834834
// it looks the atol value matters here bacause of round-off errors
835835
const double rtol = 1e-10;
836836
const double atol = 1e-13;
837+
838+
// if either segment is 0 length, they do not intersect
839+
840+
if ((x1 == x2 && y1 == y2) || (x3 == x3 && y3 == y4)) {
841+
return false;
842+
}
843+
837844
// determinant
838845
double den = ((y4 - y3) * (x2 - x1)) - ((x4 - x3) * (y2 - y1));
839846

0 commit comments

Comments
 (0)
0