Closed scottgarner closed 11 years ago
Totally out of curiosity, may I asked the case in which the vertices on their own would be useful?
Basically, given a set of points within a boundary, I want a new set of points that "avoid" these points to the greatest extent possible. Since Voronoi nodes are equidistant from three or more sites, they offer a pretty straightforward way to achieve this.
I have it working by storing an array of unique nodes while I loop through the edges, it would just be nice to avoid the extra work.
Now Voronoi.compute() will return an object with a new property, 'vertices', which is an array of unique Voronoi.Vertex objects which are required to describe the edges.
I was sceptical that this feature should be included in the core, given that in a Voronoi diagram, the Voronoi cells are what really matters, I was at first unconvinced the vertices should be returned.
But then, given that I already return an array of edges -- which I returned originally only because it allows efficient rendering, I finally decided it was only logical to do the same with vertices: similarly if someone choose to render these vertices, it can now be done efficiently, without redundancy, which wasn't possible before.
To my surprise, collecting vertices during the computation of the Voronoi diagram has no negative consequence on performance. I tested 10x 50,000 sites, removed highest and lowest measurements, then computed average time to compute the full Voronoi: Chromium = +1.8%; Firefox = -0.8%.
Great! I really appreciate the quick response. Thanks!
I'd like to access the diagram's nodes, but currently the only way I can see to do this is to look at all the edges and ignore duplicate points. Is there a more logical way to do this?
Thanks!