Fix for cart_intersect and side_by_triangle - inconsistencies on MinGW and more (robustness) #272
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is an attempt to fix the inconsistent results of sides and segment's intersection calculation on various platforms. For now I tested it on msvc10,
msvc13msvc12 and mingw-w64 4.9.1 on which different results was generated before.Before, for floating-point coordinates, the results of determinant (side_by_triangle, cramer's rule) was compared with 0, scaling the machine epsilon by the greatest absolute of compared value. This wasn't a good solution since for nearly collinear segments the results are very small. For all of them factor 1 was always used (raw epsilon) no matter how long were the segments, what coordinates were used, so how great was the error. Furthermore on various platforms different instructions are generated for the determinant expression. For some instructions sets the error of the result is proportional to the input (so a difference of coordinates). The code added in this PR scales the epsilon by the greatest absolute value of the difference of points' coordinates passed into the determinant formula. For this purpose the support for EqualsPolicy was added which can be passed to
math::detail::equals_by_policy()where is used to retrieve the epsilon factor.This PR is related to this one: #259, which was the previous attempt and this ticket: https://svn.boost.org/trac/boost/ticket/8379.
As a side effect some of the tests (e.g. difference) previously failing now passes.
This PR doesn't solve all inconsistencies, there are tests which are still failing (e.g. get_turns, enabled with a macro) but now they're doing it in a more consistent way, i.e. similar ones generates the same, wrong output.
NOTE: The PR: #267 is a part of this one so it should be merged first.