There is a circle with radius $R$ at center $(a_1, b_1)$ with the following equation
$(x-a_1)^2+(y-b_1)^2=R^2$
Then a tangent circle with radius $r$ rotated by $\theta_0$ would have the following coordinates.
$a_2 = (R+r)cos(\theta_0)+a_1$
$b_2 = (R+r)sin(\theta_0)+b_1$
But what would be the coordinates for third circle with same radius $r$ that is tangent to both circles?
What i have tried
let $t$ be the angle from central circle to the arc that ends on two tangent points. (sorry for bad english)
$t= \arcsin(\frac{2r}{R+r})+\theta_0$
the coordinates for third tangent circle with radius $r$ would be
$a_3 = (R+r)cos(t)+a_1$
$b_3 = (R+r)sin(t)+b_1$
Problem
Although the third circle (green) is tangent to central circle but its not tangent to the other circle (blue). what did i do wrong?
Also i get undefined values if $r$ is bigger than some value.