I am searching for a concept to distribute circles in a square randomly, so that they dont overlap. All circles are of the same size. The area covered by the circles can be high
@toto2 @cyborg @TokenMacGuy
Update:
I have implemented the billard solution with the FarseerPhysicsEngine and played around with it a bit. Within the process of implementing the solution I modified the problem a bit :): Instead of keeping all circles inside the box, I allow the circles to move outside the border and let the outside part reappear on the opposite side (pretty much like in the oldschool asteroids game). This makes my distribution suitable for infinite repetition in x and y direction, which is even better for the underlying Finite Element modelling task. This comes along with some other issues regarding the physics simulation, and as this was not part of the original question, I will only describe those, if anyone is particularly interested.
So what I did: I order as many circles as wanted or as fit in the most dense order possible (where the centres of the circles are in a hexagon order). I leave a margin around the circles to make the simulation more stable. It sometimes happens, that circles overlap otherwise. Every circle gets a random velocity vector and mass. Everything else is collision detection and handling, done by the physics engine.
The outcome: It works well for high amounts of circles.
If performed with a small number of circles, they tend to stick together. I cant really explain why. Might be that Fraseer doesn't model the collision as ideally elastic, so that energy is dissipated. I don't know whether, and if where, there is a property for that. As I set friction to zero for the movement, this could lead to this kind of clustering:
Anyway, I am quite happy with the result for many circles and - as this was the unsolved part so far, I suppose this will do. It's a shame, that I don't have the time to dig deeper into the other concepts, although I will for sure have a deeper look at them later on.
Thank you all for participating!! Was fun to get all your input! If you have further ideas or comments on the solution, please let me know.