Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Perform Lloyd's algorithm to find evenly spaced points in a region
ResourceFunction["LloydAlgorithm"][pts, {{xmin,xmax},{ymin,ymax}},n] performs n iterations of Lloyd's algorithm in a rectangular region. | |
ResourceFunction["LloydAlgorithm"][pts, reg,n] performs n iterations of Lloyd's algorithm in the region reg. |
Perform five iterations of the algorithm on some random points:
In[1]:= |
Out[2]= |
Spread 15 points evenly in a square box and visualize their neighborhood:
In[3]:= |
Out[5]= |
Perform 15 iterations in a complicated region:
In[6]:= |
Out[7]= |
Perform 15 iterations in a different complicated region:
In[8]:= |
Out[13]= |
See how the standard deviation of the Voronoi areas changes with iterations:
In[14]:= |
Out[15]= |
Visualize the evolution:
In[16]:= |
Out[16]= |
This work is licensed under a Creative Commons Attribution 4.0 International License