I would like to uniformly distribute a predetermined set of points within a circle. By uniform distribution, I mean they should all be equally distanced from each other (hence a random approach won't work). I tried a hexagonal approach, but I had problems consistently reaching the outermost radius.
My current approach is a nested for loop where each outer iteration reduces the radius & number of points, and each inner loop evenly drops points on the new radius. Essentially, it's a bunch of nested circles. Unfortunately, it's far from even. Any tips on how to do this correctly?
The goals of having a uniform distribution within the area and a uniform distribution on the boundary conflict; any solution will be a compromise between the two. I augmented the sunflower seed arrangement with an additional parameter
alpha
that indicates how much one cares about the evenness of boundary.alpha=0
gives the typical sunflower arrangement, with jagged boundary:With
alpha=2
the boundary is smoother:(Increasing alpha further is problematic: Too many points end up on the boundary).
The algorithm places
n
points, of which thek
th point is put at distancesqrt(k-1/2)
from the boundary (index begins withk=1
), and with polar angle2*pi*k/phi^2
wherephi
is the golden ratio. Exception: the lastalpha*sqrt(n)
points are placed on the outer boundary of the circle, and the polar radius of other points is scaled to account for that. This computation of the polar radius is done in the functionradius
.It is coded in MATLAB.
Stumbled across this question and the answer above (so all cred to user3717023 & Matt).
Just adding my translation into R here, in case someone else needed that :)