Consider the following:
pts = RandomReal[4, {10, 2}];
vor = VoronoiMesh[pts, {{0, 4}, {0, 4}}];
Graphics[{GraphicsComplex[
MeshCoordinates[vor], {Thick, Blue, MeshCells[vor, 1],
PointSize[0.02], Red, MeshCells[vor, 0], Opacity[0.2], Yellow,
MeshCells[vor, 2]}], PointSize[0.02], Point[pts[[1]]], Green,
MeshPrimitives[vor, 2][[1]]}]
Looking at the above, we see that the Voronoi sites (points that generate the Voronoi diagram) do not correspond to the Voronoi cells (in the order) generated by VoronoiMesh
. Since VoronoiMesh
discards the points used in generating the diagram, there's no obvious way I can see to align the Voronoi sites with their corresponding cells. This feels like an oversight to me, since one will have to do some complex post-processing to obtain such correspondence.
My question is: is there an easy way to obtain a site - cell alignment of the Voronoi diagram obtained via VoronoiMesh
other than using e.g. RegionMember
which seems like an unnecessary overkill when this information should be available in the Mesh
object. So e.g. with the points above, an output of the form shown below is desirable:
Transpose[{pts, MeshCells[vor, 2]}]
{{{3.15429516, 1.68154241}, Polygon[{20, 11, 6, 15}]}, {{0.925806386, 3.57266721}, Polygon[{12, 3, 1, 13}]}, {{2.12535296, 3.88158116}, Polygon[{14, 5, 8, 18}]}, {{3.52419343, 0.689832144}, Polygon[{18, 8, 7, 17}]}, {{0.590442758, 1.53821808}, Polygon[{10, 4, 9, 6, 11}]}, {{2.70632597, 3.81614775}, Polygon[{19, 13, 1, 5, 14}]}, {{2.23994147, 1.5141697}, Polygon[{15, 6, 9, 2, 16}]}, {{3.68657472, 2.93505855}, Polygon[{16, 2, 3, 12, 21}]}, {{0.12127097, 2.63380289}, Polygon[{17, 7, 4, 10, 22}]}, {{2.21266451, 2.69765978}, Polygon[{1, 3, 2, 9, 4, 7, 8, 5}]}}
vor["Properties"]
would hold the answer but no luck... $\endgroup$RelationGraph[RegionMember[#2, #1] &, pts, poly]
to make it. $\endgroup$