-
Notifications
You must be signed in to change notification settings - Fork 186
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
fix barycentric extrapolation #1701
Conversation
2201334
to
5436702
Compare
|
Double-checked and optimized: running the whole hull for each pixel was quite slow. For a visual description of the “distance to a segment” calculation, see https://observablehq.com/@fil/distance-to-a-segment |
Investigating a faster algo. |
|
I've now fixed the performance issue in #1705, bringing both algorithms to the same speed (both in theory and in practice). |
The variant in #1705 fixes a few artifacts on the edge, so that looks like a good addition to me. I haven’t grokked the algorithm yet, but I enjoyed the visual explanation of the “distance to segment” and “ray out of a convex hull” notebooks! |
* An exact algorithm, which doesn't make use of a delaunay search * repeat const * fix a floating point precision issue When points on the hull are collinear, the extrapolation fails in some regions. I've found a way to fix this by reprojecting the points (to make the hull slightly bulge out, which resolves the ties), but in the end it was too much code for a use case that is pretty bad anyway (the delaunay triangulation itself being unstable in that case). This seems to be quite enough. * test barycentric data binding --------- Co-authored-by: Mike Bostock <[email protected]>
src/marks/raster.js
Outdated
return W; | ||
}; | ||
} | ||
|
||
// Extrapolate by finding the closest point on the hull. | ||
function extrapolateBarycentric(W, I, X, Y, V, width, height, hull, index, mix) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You’re still using I
here instead of S
(the earlier confusion I mentioned).
function extrapolateBarycentric(W, I, X, Y, V, width, height, hull, index, mix) { | |
function extrapolateBarycentric(W, S, X, Y, V, width, height, hull, index, mix) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good other than the I/S comment.
Fix barycentric extrapolation Note: When points on the hull are collinear, the extrapolation fails in some regions. I've found a way to fix this by reprojecting the points (to make the hull slightly bulge out, which resolves the ties), but in the end it was too much code for a use case that is pretty bad anyway (the delaunay triangulation itself being unstable in that case). This seems to be quite enough. closes #1700 --------- Co-authored-by: Mike Bostock <[email protected]>
Fix barycentric extrapolation Note: When points on the hull are collinear, the extrapolation fails in some regions. I've found a way to fix this by reprojecting the points (to make the hull slightly bulge out, which resolves the ties), but in the end it was too much code for a use case that is pretty bad anyway (the delaunay triangulation itself being unstable in that case). This seems to be quite enough. closes observablehq#1700 --------- Co-authored-by: Mike Bostock <[email protected]>
closes #1700
Some of the tests look worse, but it's an expected artifact of the delaunay triangulation.