How to generate a set of 2D points that are roughly evenly spaced?
in
Programming Questions
•
2 years ago
Say I want to draw 100 circles to the screen, and I want them randomly placed. It's easy enough to just call
- ellipse(random(width), random(height), 5, 5)
100 times. But the resulting distribution of points is clumpy. What I'm looking for is a set of 100 points that are all roughly an equal distance from each other. My initial though is to use some sort of 2D physics simulation, with 100 particles with mutual repulsion, and run it until they stop moving. But is there a quicker way to do this? I don't want to animate the actual process of the particles (points) moving, just their final resting places. I'm sure this is a common-enough problem that there is an established algorithm for doing it.
1