Circumcircle of three circles lie on grid 
I want to calculate the circumcircle of three disks (center points is on grid points) in programming. Actually I already have a function to calculate circumcircle(s) of three disks but this function solves general-conditioned problems and a little slow (we use Mobius transform theory).
In my recent works, computation time is critical issue, and therefore I need a fast algorithm or equation of r_1, r_2, and r_3 to calculate the center point and radius of circumcircle.
All disk triplets have center points (0, 0), (0, 1), and (1, 0), and their radii are d_1, d_2, and d_3 respectively. Radii can be different and also same.
 A: The center ($x,y$) of the sought-after circle lies on the circles $(0,0,r_1+r)$, $(0,1,r_2+r)$ and $(1,0,r_3+r)$
$$x^2+y^2=(r_1+r)^2$$
$$(x-1)^2+y^2=(r_3+r)^2$$
$$x^2+(y-1)^2=(r_2+r)^2$$
Subtract two equations to eliminate $y$
$$(x-1)^2-x^2=(r_3+r)^2-(r_1+r)^2$$
$$1-2x=-r_1^2 + r_3^2 + r (2 r_3 - 2 r_1)$$
$$x=\frac{-r_1^2 + r_3^2 + r (2 r_3 - 2 r_1)-1}{-2}$$
Subtract two equations to eliminate $x$
$$(y-1)^2-y^2=(r_2+r)^2-(r_1+r)^2$$
$$1-2y=-r_1^2 + r_2^2 + r (2 r_2 - 2 r_1)$$
$$y=\frac{-r_1^2 + r_2^2 + r (2 r_2 - 2 r_1)-1}{-2}$$
We now have $x$ and $y$ as linear functions of $r$ If we insert these in $x^2+y^2=(r_1+r)^2$, we get a quadratic equation that can be solved directly for $r$
$$(-r_1^2 + r_3^2 + r (2 r_3 - 2 r_1)-1)^2+(-r_1^2 + r_2^2 + r (2 r_2 - 2 r_1)-1)^2=4(r_1+r)^2$$
Since this is a quadratic equation, there will be two solutions, you probably want the smallest positive solution. Once you have $r$, get $x,y$ from the linear formulas above.
A: This is an instance of the problem of Apollonius. On the linked Wikipedia page you can find many interesting approaches, but for computational purposes I suggest the following one:


*

*Apply a circle inversion with respect to a circle centered at $(0,r_1)$. The problem now boils down to finding a suitable circle tangent to a line and two circles;

*The locus of points which have the same distance from a circle and a line is a parabola, hence the previous point boils down to intersecting two parabolas, i.e. to solving a quadratic equation (simple);

*Apply the circle inversion again to recover the solution(s) of the original problem.


Here it is an implementation of this approach through straightedge and compass:

As an alternative, you may directly intersect two hyperbolas with parallel axis:

