# Find the angle of a tangent line between two circles

I have two circles noted as $A$ and $B$. Each of these circles has known positions $\vec{P_A}$ and $\vec{P_B}$ with radii $r_A$ and $r_B$. I need to find the angle ($\theta_A$ or $\theta_B$) shown as the blue lines protruding from the circles' origin in the diagram. These angles of theta correspond to the angle from the circles' origin to the point the tangent line intercepts the circle. The tangent line needs to follow the diagram shown above so that $\theta_A = \theta_B + 180$. These circles should also be assumed they never intercept such that $d = \lVert \vec{p_A} - \vec{p_B} \rVert > r_A + r_B$.

Hint:

Grow the circle $A$ to a radius of $r_A+r_B$ while you shrink that of $B$ to $0$. The common tangent keeps the same direction. Then you have a right triangle with sides $P_AP_B$ and $r_A+r_B$. Now you add the direction angle of $P_AP_B$ and the angle of the triangle.

Let's call the intersection of the line between centers with the common tangent $O$. Then you get two similar right angle triangles. You can also write $$|\cos\theta_A|=\frac{r_A}{||\vec{p_A}-\vec{O}||}=|\cos\theta_B|=\frac{r_B}{||\vec{p_B}-\vec{O}||}$$ You also have that $$||\vec{p_A}-\vec{O}||+||\vec{p_B}-\vec{O}||=||\vec{p_A}-\vec{p_B}||=d$$ From these, you can get $$|\cos\theta_A|=|\cos\theta_B|=\frac{r_A+r_B}{d}$$ Since $d>r_A+r_B$, you get $|\cos\theta_A|<1$