Geometry : find the points of tangency between two lines and two circles I have a programming problem. I need to find the intersection points between two lines tangent to two circles and the circles! I have the circles' radiuses and centers.

So I need points V1, V2, V3 and V4, and I have centers X1, X2 and radiuses R1 and R2.
 A: Call the intersection points of one (of the two) adjacent lines with the circle $(a,b)$ and $(c,d)$ (4 parameters). You know the distance between these points and the midpoints of the circle (two equations). The diameter connecting the midpoint of one of the circles and the intersection point of the adjacent point with that circle is perpendicular to the adjacent line (two more equations). Then you get these equations. 
$$V_1(a,b), V_2(c,d), X_1(x_{1},y_{1}), X_2(x_{2},y_{2})$$
$$R_1^2=(a-x_{1})^2+(b-y_{1})^2$$
$$R_2^2=(c-x_{2})^2+(d-y_{2})^2$$
$$\frac{b-d}{a-c}=-\frac{1}{\frac{b-y_{1}}{a-x_{1}}}$$
$$\frac{b-d}{a-c}=-\frac{1}{\frac{d-y_{2}}{c-x_{2}}}$$
The first two equations is the distance formula between two points. The last two equations uses the rule that the product of the slopes of two perpendicular lines is -1.  
Now solve these four equantions with unknowns $a, b, c$ and $d$.
A: Let be $X_1$ the center point of first circle $X_2$ of the second. $V_1$ the intersection point on the first circle $V_3$ of the second. $d$ the distance between $X_1$ and $X_2$. $r_i$ the radii. The angle $\alpha$ between $V_1X_1X_2$ is given by $\cos\alpha=\frac{R_1-R_2}{d} $ Thus $V_1$ is given by $X_1 + R_1*\hat e_\alpha$ where $e_\alpha$ points in the direction $\alpha$ right of $d$
