Fully cover a rectangle with minimum amount of fixed radius circles
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
Covering a rectangle with the minimum number of equal-radius circles is a geometric optimization problem, but there is an important caveat: the exact optimum is not something you should assume has a simple closed-form formula for every rectangle size. In practice, the useful answers are either a guaranteed covering construction or a search procedure that improves candidate layouts. The main distinction is between a mathematically exact optimum and a practical covering strategy that is easy to compute and implement.
Start with the Geometry
Suppose the rectangle has width W, height H, and each circle has radius r. A circle covers every point within distance r of its center. To cover the rectangle, every point in the rectangle must lie inside at least one circle.
A tempting but wrong shortcut is to divide rectangle area by circle area:
This gives only a lower bound. It does not tell you how many circles are actually needed, because circles overlap and edge effects matter.
Guaranteed Square-Grid Covering
A simple constructive method comes from the square that fits inside a circle. A circle of radius r contains an axis-aligned square of side length sqrt(2) * r.
So one guaranteed way to cover the rectangle is:
- tile the rectangle with squares of side
sqrt(2) * r - place one circle at the center of each square
Then every point of each square is inside its circle.
This construction is easy and correct, but not always minimal.
Hexagonal Layout Is Usually Better
For covering the plane efficiently, staggered rows often outperform a plain square grid. A practical hex-like layout uses:
- horizontal spacing near
sqrt(3) * r - vertical spacing near
1.5 * r
The idea is to offset alternate rows so each row fits into the gaps of the previous one.
This is a useful heuristic construction, especially when the rectangle is large relative to the circle size. But again, “useful” is not the same as “proven minimal for every dimension.”
Lower Bounds and Exact Search
If you truly need the minimum, you need more than one formula. A common workflow is:
- compute a lower bound
- build a valid covering with some heuristic
- try to reduce the circle count with search or optimization
For small instances, you can discretize candidate center locations and search combinatorially. For larger instances, that becomes expensive quickly.
A rough lower bound is:
But because edge and overlap effects are significant, the real answer may be substantially larger than this lower bound.
Validate Coverage Numerically
Whatever layout you choose, you should verify it. One pragmatic method is to sample points on a fine grid and confirm every sample point lies within at least one circle.
This is not a formal proof at arbitrary resolution, but it is a useful engineering check when experimenting with layouts.
A Practical Strategy
If you are solving a real application such as sensor placement or sprinkler coverage, a good practical approach is:
- start from a hex-like pattern
- test whether it covers the rectangle
- adjust boundary rows and columns
- compare against a square-grid upper bound
That usually gets you to a strong solution faster than chasing an exact symbolic answer that may not exist in simple form.
Special Cases
Some special cases are easy:
- if
2r >= diagonal of rectangle, one circle is enough - if
2r >= H, then the problem reduces to covering the width with overlapping intervals
Example:
Checking simple cases first can simplify the rest of the algorithm.
Common Pitfalls
The biggest mistake is assuming that dividing area by circle area gives the answer. Another is confusing packing with covering; covering allows overlap and has different geometry. Developers also often mistake a convenient grid construction for a proven minimum. Finally, if you test a layout numerically, a coarse sampling grid can miss uncovered boundary regions and give false confidence.
Summary
- Exact minimum circle covering of a rectangle is not generally a one-line formula problem.
- A square-grid construction gives a simple guaranteed upper bound.
- A staggered hex-like layout is often a better practical covering pattern.
- Area-based calculations provide lower bounds, not exact answers.
- If minimum really matters, combine bounds, candidate constructions, and explicit coverage validation.

