Ideas for an algorithm for random distribution of circles in a square

前端 未结 6 733
孤城傲影
孤城傲影 2021-02-08 15:18

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

6条回答
  •  别那么骄傲
    2021-02-08 15:51

    2 ideas:

    Instead of thinking of the square as a closed box, take the top away and allow the circles to fall under the effects of gravity into the open box. By altering the position of the circles before they fall you create randomness. This might be the same or similar to your billards example.

    or

    Use Quadtrees to divide up the space in the box and place randomly checking for overlap using collision detection, which in this case might only need to be the center of the circle to another center is greater than double the radius and the walls of the box are greater than a radius away. By using quadtrees this will make the algorithm more efficient.

提交回复
热议问题