Function Repository Resource:

ApproximateGeneralizedVoronoiMesh

Source Notebook

Approximate the generalized Voronoi mesh for non-overlapping geometries

Contributed by: Lakshay Garg

ResourceFunction["ApproximateGeneralizedVoronoiMesh"][{g1,g2,}]

gives a MeshRegion that approximates the Voronoi mesh of curves approximated by the 2D points in lists g1,g2,.

ResourceFunction["ApproximateGeneralizedVoronoiMesh"][{g1,g2,},{{xmin,xmax},{ymin,ymax}}]

clips the mesh to the bounds [xmin,xmax]⨯ [ymin,ymax].

Details and Options

ResourceFunction["ApproximateGeneralizedVoronoiMesh"] takes the same options as MeshRegion.

Examples

Basic Examples (1) 

Generate the Voronoi mesh for some points, lines and a parabola:

In[1]:=
With[
 {parabola = Table[{t, 1.7 - t*t}, {t, -0.5, 0.5, 0.1}],
  line1 = Table[{t, t}, {t, 0, 1, 0.1}],
  line2 = Table[{t - 0.7, -0.5 - 0.1 t}, {t, 0, 1, 0.1}],
  point1 = {1, 0}, point2 = {0, 1}},
 Show[
  ResourceFunction["ApproximateGeneralizedVoronoiMesh"][
   {parabola, line1, line2, {point1}, {point2}},
   {{-1, 2}, {-1, 2}}],
  ListLinePlot[parabola],
  ListLinePlot[line1],
  ListLinePlot[line2],
  ListPlot[{point1, point2}]]]
Out[1]=

Possible Issues (1) 

Since MeshRegion cannot contain polygons with holes, the Voronoi meshes which contain such polygons will contain edges so that such polygons can be represented without holes:

In[2]:=
With[
 {circle = Table[AngleVector[t], {t, 0, 2 Pi + 0.1, 0.1}],
  point1 = {{-0.5, 0}},
  point2 = {{0.5, 0}}},
 Show[
  ResourceFunction["ApproximateGeneralizedVoronoiMesh"][
   {circle, point1, point2}, {{-1.2, 1.2}, {-1.2, 1.2}}],
  ListLinePlot[circle],
  ListPlot[point1],
  ListPlot[point2]]]
Out[2]=

Publisher

Lakshay Garg

Version History

  • 1.0.0 – 31 March 2020

Related Resources

Author Notes

If one is not interested in a MeshRegion but only the polygons, here’s an alternative approach which handles polygons with holes gracefully

License Information