Voronoi and Delaunay

Based on code from Joseph O’Rourke.

Generate some 2D points with coords in [-1, 1]:

npts=20;
pts=RandomReal[{-1,1},{npts,2}];

Delaunay triangulation

Create and store the Delaunay triangulation:

dm=DelaunayMesh[pts];
gDT=HighlightMesh[dm,{Style[0,Blue,PointSize[Medium]],Style[1,Purple],Style[2,Opacity[0.2],Cyan]}]

Extract the indexes of the triangles:

Δs=MeshCells[dm,2];

listOfIndices=Table[Δs[[i]][[1]],{i,1,Length[Δs]}];

listOfTriPts=Table[pts[[listOfIndices[[i]]]],{i,1,Length[Δs]}];

listOfSpheres=Circumsphere/@listOfTriPts;

Create an animation showing the Delaunay triangulation and circumcircles:

Manipulate[Show[gDT,Graphics[{LightGreen,Polygon[listOfTriPts[[i]]],Green,listOfSpheres[[i]]}],PlotRange->{{-2,2},{-2,2}}],{i,1,Length[listOfTriPts],1}]

Voronoi diagram

Create and store the Voronoi diagram:

vm=VoronoiMesh[pts];
gVD=HighlightMesh[vm,{Style[0,Orange],Style[1,Brown],Style[2,LightYellow]}]

Voronoi and Delaunay

Now show both the Voronoi diagram and the Delaunay triangulation:

Show[gVD,gDT]