Skip to content
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

Easy Access to Voronoi Points/Nodes #4

Closed
scottgarner opened this issue Apr 22, 2013 · 4 comments
Closed

Easy Access to Voronoi Points/Nodes #4

scottgarner opened this issue Apr 22, 2013 · 4 comments

Comments

@scottgarner
Copy link

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!

@gorhill
Copy link
Owner

gorhill commented Apr 22, 2013

Totally out of curiosity, may I asked the case in which the vertices on their own would be useful?

@scottgarner
Copy link
Author

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.

@gorhill
Copy link
Owner

gorhill commented Apr 22, 2013

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%.

@gorhill gorhill closed this as completed Apr 22, 2013
@scottgarner
Copy link
Author

Great! I really appreciate the quick response. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants