Open Andrew-Reid opened 6 years ago
The demo is quite nice and I can totally see how it will be useful for some of my projects — but IMO there is no dire need to add it to the d3-voronoi module, as it is quite easy to add externally.
Updated this method to d3-delaunay: https://bl.ocks.org/Fil/3faaaf1b5f34b03a7a2235bf22e20b73
The d3.voronoi module has the handy
voronoi.find(x,y,r)
(#17 ) method, which returns the closest site to a given point, which is very useful for a number of applications. But what if we wanted all the sites within a given radius?I've been working on a few things where a built in method would be handy, but also saw a question question on StackOverflow yesterday on the same topic that got me thinking, if we have a method to find the closest site, why not a method to find all sites within a given radius?
I've mocked up a potential method here, it takes the same parameters as
voronoi.find
, but spits out an array of sites rather than a single one.And here's a demonstration.
Granted, this implementation leads to some cells potentially being examined more than once (first through the use of
voronoi.find()
to get the initial cell); consequently, it could be re-worked to include a slightly modified voronoi.find() method to get started.But, this might be getting ahead of myself. Is there value in including such a method in d3.voronoi?