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

Voronoi edges() and connected neighbors() convenience functions #97

Closed
nemo9955 opened this issue Jan 13, 2020 · 4 comments
Closed

Voronoi edges() and connected neighbors() convenience functions #97

nemo9955 opened this issue Jan 13, 2020 · 4 comments

Comments

@nemo9955
Copy link

There should be functions for voronoi.neighbors() that returns the connected edge cells of the structure and voronoi.edges() for the edge cells .

I was shocked when I found this this observable after implementing a few hacks to prevent a messy graph, searched quite some time for a solution and found nothing. Maybe as an Issue other people will see the solution at least.

https://observablehq.com/@fil/unconnected-delaunay-neighbors?collection=@fil/voronoi

@Fil
Copy link
Member

Fil commented Jan 13, 2020

Closing as duplicate of #96

Is this something that should be mentioned in the documentation?

@Fil Fil closed this as completed Jan 13, 2020
@nemo9955
Copy link
Author

Yes, if simply put in documentation would have been great for me.
Maybe as a footer with related algorithms/examples.

@Fil
Copy link
Member

Fil commented Jan 19, 2020

voronoi.neighbors are now available, thank you for the suggestion.

As to the suggestion for voronoi.edges(), would this be a manner of getting a list of cells that are clipped out? Note that some cells might be clipped out entirely and are not rendered at all. I'm wondering about the use case, but a solution might be to compare delaunay.neighbors(i).length and voronoi.neighbors(i).length : if they are equal then we have a "central" cell, if different an "edge" cell, and if voronoi.neighbors(i).length === 0 we have an "invisible" cell.

@nemo9955
Copy link
Author

Basically I wanted to draw cells as a "river" from top to bottom , but the graph jumped the cells at the edge as they had smaller cost.
I adapted this code to get a boolean check of an edge cell (it was true for not rendered ones) and increased the cost of the graph edge if it was connected to an edge cell ... a big hack.
After implementing the true neighbors, I did not need to increase cost or create cells outside the view, so the edge request is redundant for me.
Thank you!

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