# Finding a circle that touch two other circles and a line

Given two circles $(x_1, y_1, r_1), (x_2, y_2, r_2)$ and a line passing through two points $A(x_a, y_a)$ and $B(x_b, y_b)$. How to find a circle $(x_3, y_3, r_3)$ that is tangent to line and two given circles?

I need an algebraic equations not geometric construction.

• Commented Jan 12, 2013 at 19:05

Let's say $\epsilon$ is the line defined by A and B and $K_1,K_2$ and $K_3$ the centers of the given circles.

Then we have the following 3 equations that will help us define $x_3,y_3,r_3$

$1$. $\sqrt{(x_3-x_2)^2+(y_3-y_2)^2}=r_3+r_2$ or $\sqrt{(x_3-x_2)^2+(y_3-y_2)^2}=|r_3-r_2|$

That is, the distance of the centers $K_2,K_3$ equals the sum of the radius $r_3,r_2$ if the circles are tangent outwardly or the $|r_3-r_2|$ if they're tangent inwardly.

$2$. $\sqrt{(x_3-x_1)^2+(y_3-y_1)^2}=r_3+r_1$ or $\sqrt{(x_3-x_1)^2+(y_3-y_1)^2}=|r_3-r_1|$

$3$. The distance of the $K_3$ from $\epsilon$ equals $r_3$ if you write $\epsilon :Ax+By+C=0$ then $r_3=\frac{|Ax_3+By_3+c|}{\sqrt{A^2+B^2}}$

• We obtain tree equation (1)-(3) where x3, y3, r3 are unknown. How to solve them? Commented Jan 12, 2013 at 21:42
• From equation 3 you can easily compute $r_3$ just substitute everything you know. Then substitute everything you know in equations 1 and 2 and subtract equation 1 from 2 (or 2 from 1 it's the same) to get rid of the squares. Solve what is left so that $x_3=....$ substitute again and you're done... Lot's of things to do I know... Commented Jan 12, 2013 at 22:00
• I've solved the problem using Wolfram MathWorld page and some additional calculation. Thank you! Commented Jan 13, 2013 at 12:37
• Glad I could help :) Commented Jan 13, 2013 at 13:55