Expand description
Apollonius and tangent-circle constructions (#159, ledger row B14).
tangent_circles finds every circle tangent to three given points,
lines or circles, in any combination – the classical Apollonius problem
(three circles), its ten degenerate variants (mixing in points and
lines), and everything in between.
§Method
A tangency to a candidate circle (c, r) is one algebraic equation per
constraint, all sharing the same shape after multiplying through:
a * (|c|^2 - r^2) + b . c + d * r + f = 0
where a = 1 for a point or circle constraint (a = 0 for a line), and
a per-constraint sign choice s in {-1, 1} selects which of the two
tangency senses d encodes (internal/external for a circle, which side
for a line; a point has only one sense, so its sign does not change the
equation). Three such equations, one per constraint, are eliminated in
closed form: subtracting the quadratic-type equations from each other
cancels their shared |c|^2 - r^2 term, leaving two equations linear in
(cx, cy, r); solving those for cx and cy as affine functions of r
and substituting into the remaining quadratic equation gives a quadratic
in r alone (linear when every constraint is a line). Every sign choice
(up to eight) is tried; every real root with a positive radius is a
solution, deduplicated and returned in a deterministic order.
This is the standard “linearization” solution to Apollonius’ problem (see e.g. Coakley 1860, or Gisch and Ribando’s 2004 survey for the algebraic form used here), extended uniformly to points and lines rather than special-cased.
§Scope
Not covered: two circle- or point-type constraints centred at the same
point. Their equations then differ only in the radius term, with no
cx/cy coefficient left to eliminate against, which is singular under
every sign choice in the elimination this crate uses (a solution family
can still exist; finding it needs a different elimination order). This
is refused as TangencyError::Degenerate, not answered wrong.
Enums§
- Tangency
Error - Why
tangent_circlescould not be solved. - Tangent
- A point, line or circle a solution circle must be tangent to (a point counts as a zero-radius circle, tangent when the solution circle passes through it).
Functions§
- tangent_
circles - Every circle tangent to
constraints[0],constraints[1]andconstraints[2], in any combination of point, line and circle.