Åsberg
Sunflower Pattern
I recently needed a way of uniformly distributing a set of points inside a circle. When I thought about this I remembered having watched Sebastian Lague’s video about boids. In it he discusses uniformly distributing points on a sphere and takes the route via points in a circle, exactly my problem.
In his video, Lauge plays with the distribution of these dots for a while in what looks like a nice little interactive tool. So, getting as side tracked as he did, I created my rendition of that tool. With that, I too could play with the dots a bit before returning to my original task. Try it out yourself!
Simplified, the algorithm behind this works out to: begin in the center, with increasing distance place dots in a spiral rotating some angle for each dot. Now, the full version of this algorithm is that the distance from the center for each dot should be raised to some power , lets set it to to begin with. The angle to turn for each dot should be times some . With only this information, you wont be able to easily produce the uniform distribution we seek. If we set the to the golden ratio (), the most irrational number, we magickly get a sunflower pattern. This also happens to be the number we need to uniformly distribute the dots, but we also need to set (the power we raise the distance to) to , effectively taking the square root. You can read more about the theory from this Stackoverflow.com answer.
As for how I created my interactive tool: I used React, something I’ve only recently been a fan of but now am a big fan of; my own UI frame work Syngg; and some spaghetti code. Nonetheless, you can find the source on my GitHub.