-
Notifications
You must be signed in to change notification settings - Fork 58
delaunay.find returns zero when it should not #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
From what I see, it comes from the poor precision of area, which in this case return ~2e-10 (instead of 0 as the points are collinear). As a consequence, the test at https://github.com/d3/d3-delaunay/blob/master/src/delaunay.js#L53 is skipped, and the collinear "hack" doesn't kick in. Which means we have no neighbors for (0), and find stops there. tldr: We need a better formula for area. |
Would it also work to alter the threshold for collinearity to be a bit higher than the current value of |
We can fiddle and move thresholds around, but the risk is that, while it would solve the issue for this specific set of values, it might break for another. What we want is probably a larger set of test cases, a more precise area computation, or a different strategy. |
just tried this in my notebook and the area is evaluated as 1.1641532182693481e-10 ; better than 2.3283064365386963e-10 but still not good enough. A way to get to a very nice and round 0 is to substract hull[0]'s coordinates from each subsequent point… but isn't this cheating?
|
Ref. d3/d3-array#35 |
In this case, we can tell the collinearity because the triangles returned is empty. See #93 for a solution that includes this, a kahan summation and a translation by -point[hull[0]]. |
I've updated #93 with much saner solution (faster, more accurate, and with less code). |
Since we have a triangulation, there's no need to compute the whole area. The first non-degenerate triangle we find tells us that the triangulation is not collinear. This returns immediately in the general case — and it's more accurate in the degenerate cases; and less code!
Since we have a triangulation, there's no need to compute the whole area. The first non-degenerate triangle we find tells us that the triangulation is not collinear. This returns immediately in the general case — and it's more accurate in the degenerate cases; and less code!
fixed in c403f4b thank you Lauren for the report |
I maintain a cloned and slimmed down version of
d3-delaunay
, and recently had the following edge case brought to my attention:I find that it fails when added to your test suite as well.
See FormidableLabs/delaunay-find#9 for original report
The text was updated successfully, but these errors were encountered: