How this calculation works
Find room for a circle that stays inside a convex boundary and avoids specified point obstacles. The answer includes a feasible radius, an upper radius bound and their remaining gap, so a visually plausible center is not mistaken for an exact optimum.
r(c)=min_i(b_i−n_i·c, min_j ||c−s_j||); maximize r(c).A worked example
Inside the square [−1,1]² with an obstacle at the origin, a maximizing center has coordinates (a,a), up to square symmetries. Equal clearances give √2a=1−a, hence a=√2−1 and optimal radius2−√2≈0.58578644. The search returns an interval containing that value.
Good to know
3–20 consecutive convex vertices, 1–30 point obstacles; polygon diagonal≤1000. Absolute radius tolerance0.0001–0.1. Lipschitz branch-and-bound capped at150000 boxes; cap failure returns no claimed optimum. Obstacles have zero radius. Floating bounds include numerical roundoff, not exact rational certification.
Reference: Method reference (opens in a new tab) ↗
The circle must satisfy two kinds of clearance
For each polygon side, the inward clearance is its signed perpendicular distance from the center. Using unit outward normals makes those distances share the coordinate unit with the circle radius.
Every obstacle adds a Euclidean-distance constraint. A circle can touch an obstacle point, but its open interior must exclude it. A site outside the polygon can still constrain a nearby circle; no obstacle is silently discarded.
Compare this with the Largest inscribed ball calculator from linear inequalities. An inscribed circle without internal sites does not solve an empty-clearance problem.
Enter geometry in one Cartesian unit
List the polygon around its boundary, clockwise or counterclockwise. The implementation normalizes orientation, checks convex supporting half-planes and rejects repeated edges or a zero-area region.
Point sites are coordinates, not polygon vertices or disks with physical size. Latitude and longitude require a suitable projection first. A tolerance of0.001 means an absolute radius difference in the same units, not a percentage error.
Why subdivision gives a useful bound
Distance to a fixed site is1-Lipschitz, as is signed distance to a supporting line. The minimum of these clearances is also1-Lipschitz. Within a box of half-diagonal h, its value cannot exceed the center value plus h.
The algorithm keeps promising boxes in an upper-bound priority queue. Evaluating a box can improve the feasible lower bound; subdivision shrinks its uncertainty. A box whose upper bound cannot beat the incumbent needs no further work.
Solve the square example by equal contact
With one point at the square center, symmetry suggests four equally good diagonal locations. For a center(a,a) in the first quadrant, nearest-side clearance is1−a and obstacle clearance is√2a.
Their minimum is largest where they meet. Solving1−a=√2a gives the stated a and radius. This checks both the objective and the convention that touching is allowed, rather than comparing only a screenshot of the circle.
Read the interval before rounding
The returned radius is achieved at the reported center, subject to floating-point precision. The upper value bounds all unpruned boxes by the Lipschitz argument, and the displayed gap is the stopping quantity.
Two different centers can attain the same optimum. A small gap certifies radius resolution under this computation, not uniqueness of location. Rounding center coordinates before reconstructing the circle can slightly reduce clearance.
When the computation should stop without an answer
Very thin polygons, extreme scale and tiny requested gaps can make a bounded search expensive. Exceeding the state cap produces an explicit error instead of a partial answer labeled maximum.
This is a planar convex-boundary problem with point obstacles. Concave walls, finite obstacle radii, geodesic distance and nonoverlapping multi-circle packing require different constraints and are not inferred from this input.
Use clearance as a design diagnostic
Compare edge clearances with site clearances to identify what limits the proposed circle. A near-equal pair can explain why moving toward one empty-looking region makes the boundary constraint worse.
For placement design, rerun after moving the actual obstacles or changing the polygon, then compare the feasible radii. The mathematical radius does not include safety buffers, manufacturing uncertainty or an allowance for measurement error.
A few questions, answered
Is this the largest inscribed circle?
Internal point obstacles can make its radius smaller than the polygon's inscribed-circle radius; the constraints differ.
Can an obstacle touch the circle?
Yes. The circle boundary may pass through a point obstacle; the open interior may not contain it.
Why are there two radius values?
The feasible radius is a lower bound and the remaining box bounds give an upper value. Their difference controls stopping.
Does the center have to be unique?
No. Symmetric inputs can have several maximizing centers, as in the prefilled square.