d3-hierarchy
d3-hierarchy copied to clipboard
Fixed a problem with large values in packEnclose
I have added a test showing how packEnclose is failing with the x,y values above 1e5. It runs out of precision and throws an Error at line 46 during the front propagation.
I've added translation of the circles to encloseBasis3, so that the overall values are smaller.
The time complexity is intact. I had to update the expected result in the edge case test (precision change).
Thank you for the wonderful algorithm implementation!
Example
const circles = [
{ "x": 531214.7271532917, "y": 360738.8204573899, "r": 10 },
{ "x": 531242.0429781883, "y": 360764.87727581244, "r": 10 },
{ "x": 531239.7927335791, "y": 360716.54336245544, "r": 10 }
];
assert.doesNotThrow(() => packEnclose(circles));
Looking good! Note that these should be named large values rather than big numbers (because of precedent).
@Fil I changed the wording