forked from akavel/polyclip-go
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Discard non-reductive segment divisions that otherwise recurse infini…
…tely. (#1) Floating point imprecision in findIntersection() can create "non-reductive" divisions that result in infinite recursion. One class of non-reductive divisions can be detected at segment division time; divisions that result in segments going in the wrong direction (including zero-length segments, which have no direction) are non-reductive. This is detected by checking if endpoint.isValidDirection() in divideSegment(). The other class of non-reductive divisions does create "valid" segments, but one being infinitesimally small, and the other which recurses into a similar non-reductive division. This happens when the left or right endpoints of the two segments are very close but not equal, the problematic division for which manifests as an intersection point falling outside of the endpoints on a horizontal or vertical line. Note that theoretically, both classes of non-reductive division could be detected by comparing the length of the original segment against the length of the resulting segments, the latter of which should always be less than the former. Unfortunately, computation of segment length is subject to floating point imprecision and can introduce false positives. The rationale behind the current approach (isValidDirection and isValidSingleIntersection) is to rely only on boolean comparisons.
- Loading branch information
Showing
5 changed files
with
403 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.