How many squares can be packed into a circle?

前端 未结 4 404
北恋
北恋 2020-12-31 20:53

How many squares of size a×a can be packed into a circle of radius R?

I don\'t need a solution. I just need some kind of a starting idea.

4条回答
  •  清歌不尽
    2020-12-31 21:31

    Rasterise the circle using something like the midpoint circle algorithm. The number of filled pixels is the number of squares you can fit in the circle. Of course, since you're not actually filling the pixels, just counting them, this should take time proportional to the circumference of the circle, not its area.

    You'll have to pick the radius for rasterisation carefully, so that you only count pixels that are strictly inside the circle.

    Edit: This may not be exactly correct, as it's possible that applying a sub-pixel offset to the grid could change the result. I'll leave the answer here as it may provide a useful starting point for an exact solution.

提交回复
热议问题