Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 325d0ce

Browse filesBrowse files
committed
MNT: alternate method of identifying 0 length segments
Use length square being close to 0 rather than strict. I have a worry that because we are using "close" for identifying the determinant is 0, if we use strict equality for the length, then we may pass through the length check, but erroneously go through the den == 0 path.
1 parent 7ff95a4 commit 325d0ce
Copy full SHA for 325d0ce

File tree

Expand file treeCollapse file tree

1 file changed

+5
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+5
-1
lines changed

‎src/_path.h

Copy file name to clipboardExpand all lines: src/_path.h
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -836,8 +836,12 @@ inline bool segments_intersect(const double &x1,
836836
const double atol = 1e-13;
837837

838838
// if either segment is 0 length, they do not intersect
839+
// length-squared of each segment
840+
const double lensq_A = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
841+
const double lenqs_B = (x3 - x4) * (x3 - x4) + (y3 - y4) * (y3 - y4);
839842

840-
if ((x1 == x2 && y1 == y2) || (x3 == x3 && y3 == y4)) {
843+
// one of the segments is 0 length
844+
if (isclose(lensq_A, 0, rtol, atol) || isclose(lenqs_B, 0, rtol, atol)) {
841845
return false;
842846
}
843847

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.