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 <mbostock@gmail.com>
src/marks/raster.js
Outdated
| } | ||
|
|
||
| // 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.
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) { |
mbostock
left a comment
There was a problem hiding this comment.
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 <mbostock@gmail.com>
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 <mbostock@gmail.com>
closes #1700
Some of the tests look worse, but it's an expected artifact of the delaunay triangulation.