delaunator-cpp icon indicating copy to clipboard operation
delaunator-cpp copied to clipboard

orient function robustness issue

Open MFraters opened this issue 1 year ago • 1 comments

I found that line https://github.com/delfrrr/delaunator-cpp/blob/c1521f6e879881232dcddabd6c2ddb6187e8714b/include/delaunator.hpp#L76 can cause differences between debug and release mode in some edge cases. In debug mode the result is exactly zero, which means the line evaluates to false, but in release mode the result is a very small negative number.

This can be prevented by using return (qy - py) * (rx - qx) - (qx - px) * (ry - qy) < -std::numeric_limits<double>::epsilon(); instead, which seems to solve the problem in my case (the value is on the order of -1e-21). I am curious to know if this is a good solution in general and I am happy to make a pull request out of it if desired.

For reference: https://github.com/GeodynamicWorldBuilder/WorldBuilder/pull/479

MFraters avatar Apr 07 '23 23:04 MFraters

Dealt with here: https://github.com/abellgithub/delaunator-cpp

abellgithub avatar Jan 18 '24 19:01 abellgithub