Advanced maths

Circle packing in a rectangle feasibility calculator

Equal-circle packing feasibility asks whether a requested number of circles can fit without overlap inside a rectangle.

Your numbers

Positive coordinate length.
Positive coordinate length.
Positive; all circles have this radius.
Integer 1–400.

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

Equal-circle packing feasibility asks whether a requested number of circles can fit without overlap inside a rectangle. This calculator searches a bounded collection of rectangular and staggered hexagonal row layouts, checks pairwise and wall clearances, and returns a concrete layout when one is found. Search failure remains inconclusive unless a necessary bound proves impossibility.

THE FORMULAr≤x_i≤W−r, r≤y_i≤H−r, ||c_i−c_j||≥2r.

A worked example

Four circles of radius one fit in a 4×4 rectangle at centers (1,1),(3,1),(1,3),(3,3). Neighboring circles touch with separation two and boundary clearance zero. Their total area is 4pi, leaving unused rectangle area even though every row is tightly packed.

Good to know

Equal circles only, count 1–400, rectangle sides and radius within the printed positive limits. Candidate families are bounded grids and staggered rows in both orientations, not a global optimizer. Failed search is not an impossibility proof except for diameter or total-area bounds. Clearances use floating-point tolerance.

A feasible answer needs actual center coordinates

The output lists one center per placed circle and verifies that every center lies at least one radius from all four walls. It also checks every pair separation against twice the radius. This makes a successful result independently inspectable instead of relying on an area fraction or an attractive diagram alone.

Tangency is permitted: a zero clearance means two circles or a circle and wall touch without overlap. The comparison allows a small numerical tolerance scaled to the geometry. For fabrication or clearance-critical design, add a physical margin to the radius rather than treating numerical tolerance as usable space.

Four unit circles touch inside a four by four squareRadius: 1Wall clearance: 0Separation ≥ 2Feasible; not optimality
Centers (1,1),(3,1),(1,3),(3,3) give pair separation at least two and nonnegative wall clearance in a 4×4 rectangle. This is a verified feasible layout, with no claim that the candidate search proves optimality for other inputs.

The Clearance for a diagonal inside a rectangular box calculator covers a related task. This page focuses on circle packing in a rectangle feasibility calculator with the method limits and worked example described below.

Necessary bounds can prove only certain failures

If a diameter exceeds either rectangle side, even one circle cannot fit. If the requested total disk area exceeds rectangle area, the entire request is impossible. Both are valid necessary conditions, but passing them is not sufficient because unused gaps between circles cannot always be rearranged into usable space.

A failed rectangular or hexagonal candidate can therefore occur even when some irregular layout exists. The page reports that outcome as inconclusive. It never labels the largest candidate count found as a proven maximum, and it does not turn a high area fraction into evidence that the geometry is feasible.

Orientation changes which row family fits

Staggered rows use vertical spacing sqrt(3) times the radius and alternate a horizontal shift. Testing both rectangle orientations helps find layouts that fit better when the long direction hosts the rows. Several starting shifts are included, but this remains a finite candidate collection rather than an exhaustive placement search.

The diagonal-clearance calculator tests one geometric object against a box, whereas circle packing involves all pair interactions simultaneously. A returned coordinate layout can be used as a starting point for further optimization. To prove optimality or impossibility beyond the printed bounds, a substantially stronger geometric search or mathematical certificate is needed.

A few questions, answered

Does failed search mean the circles cannot fit?

Usually no. It means these candidate layouts failed; only the stated necessary bounds certify impossibility.

Can touching circles count as feasible?

Yes. Tangency is allowed. Increase the input radius if a practical separation margin is required.

Find your calculator

Start typing to explore the library.