nodename / as3delaunay

Delaunay triangulation and Voronoi diagram for Flash (Flash Builder 4 project)
http://nodename.github.com/as3delaunay/
MIT License
157 stars 104 forks source link

Get neighbor sites in Voronoi diagram #9

Closed Domiii closed 9 years ago

Domiii commented 9 years ago

Is there an easy way to get neighboring sites of a site of the Voronoi diagram, where "site A is a neighbor of site B" implies that site A and B share an edge in the Voronoi diagram?

As explained in this related issue, the current getNeighborSitesForSite method should be renamed to getDelaunayNeighborSitesForSite or so, to indicate that this is not a neighbor in the sense of the Voronoi, but only in the sense of the Delaunay graph, which includes additional edges to ensure convexity of the triangulation.

I am thinking that since the current getNeighborSitesForSite method yields a superset of the wanted Voronoi neighborhood, one could easily attain this goal, if there was a method to determine whether two sites share an edge in the Voronoi diagram. I have not found such a method, but maybe I was not looking hard enough?

nodename commented 9 years ago

The neighbor sites are indeed what you are looking for. They are not a superset. The Delaunay line segment that connects them is perpendicular to the Voronoi region boundary between them but need not intersect that region boundary. If you zoom out by increasing the bounding rectangle or shrinking the site coordinates you will see the boundary shared by the two regions. This is just like several pairs of neighboring regions near the center of your sample picture, where the Delaunay connection between two sites does not intersect their region boundary. The Delaunay triangulation is precisely the dual of the Voronoi diagram. A neighbor is a neighbor, viewed either way.