I'm working on a program that draws the limit sets of Schottky groups defined by pairs of circles. If circle $C$ with radius $r$ is centered at $P$, then to map that circle to some other circle $C'$ with radius $s$ centered at $Q$, one can use the transformation $T(z) = \displaystyle{\frac{s(z-P)+rQ}{r}}$ with matrix representation $T = \begin{bmatrix} s & -sP + rQ \\ 0 & r \end{bmatrix}$.
I'm currently using the algorithm to perform Moebius transforms on circles as detailed on pg. 91 of the book Indra's Pearls, which gives equations for these parameters as
$\begin{align*} z &= P - \frac{r^2}{\overline{\displaystyle{\frac{d}{c}}+P}} \\ Q &= \frac{az+b}{cz+d}\\ s &= \left | \frac{a(P+r)+b}{c(P+r)+d} \right | \end{align*}$
for a Moebius transformation $T(z)=\displaystyle{\frac{az+b}{cz+d}}$. To be honest I don't really understand how it works.
However, this leads to a division by zero for the given transformation in the $z$ equation. Is there a way to avoid this, or possibly an alternate transformation I could use?