Closed form solution to a problem of tangent circles

I have two circles, that I know are both tangential to a third (unknown) circle. I also know what quadrants of the circles the tangential points are in. It is as pictured below. I also know the arc angle that the third circle spans between the two tangential points (beta).

I would like to know the location of the two tangential points, as well as one of the tangential directions, so I can draw the unknown (red) circle.

I currently have a working solution for this involving a nonlinear equation solver. If at all possible I would like to have a solution that involves no non-linear equation solving, because I need to run very many of these problems and I need precise results.

• @ritwiksinha Everything written in black is known.The central points, the radii, and the arc angle. – Rikki-Tikki-Tavi Jul 2 '16 at 11:53

First let us solve the radius of your circle. You can see that the centers of the circles form a triangle. There are 8 possible triangles, of which 4 are mirror solutions across the line that connects the centers of your original circles. The other solutions are permutations of inside tangent and outside tangent connections.

Image 1: All possible solutions

So knowing the quadrant is hardly enough for the choice of solution.

Solving the triangles

So for eaxmple let the circle be on the inner outside of both circles (the sign changes for the other solutions). Now you need to solve the equation:

$$D^2=(x+r_1)^2+(x+r_2)^2-2(x+r_1)(x+r_2)\cos(\beta)$$

Now this can be solved in a computer algebra system and gives 2 solutions with numerous corner constraints (do it yourself it's important for robust code and obviously you need 4 solutions to check.)

$$x=\frac{1}{2} \left(\pm\sqrt{\frac{\cos (\beta) (r_1-r_2)^2-2 D^2+(r_1-r_2)^2}{\cos (\beta)-1}}-r_1-r_2\right)$$

Once you have x solved you can solve the center. This can be done in many ways but I would proceed by solving angle $\alpha$ and some vector rotation, normalization and scalar multiplication. Same calculation can be used to find the intersection point and the tangent is just this vector rotated by 90 degrees.

You could also use an alternate formulation with 2 angles and a vector sum of $a+b-c=0$, with 2 unknowns and 2 equations.

• Thank you. Looking at the solutions, I think knowing the quadrants where the circles touch is sufficient, if I also know the direction of curvature. – Rikki-Tikki-Tavi Jul 4 '16 at 13:57
• Could you please elaborate on what you would do with the given data and radius $x$ to obtain the tangential points and directions? – Rikki-Tikki-Tavi Jul 4 '16 at 15:51
• @Rikki-Tikki-Tavi, What part do you not know how to compute: The other angles of a triangle (use law of sines) or vector rotation? If you look at the image you'll see that 2 of the solutions are in same quadrant. I would Instead use whether or not its the inside or outside tangent, or then you need to check all of them. (by the way it feels like I'm teaching you your high school trig again as i have taught you Law of Cosines already) – joojaa Jul 4 '16 at 17:20