I'm going to replace the variable names $A_c, A_r, B_c, B_r$ with $C_1, r_1, C_2, r_2$ respectively.
There are several ways to tackle finding the the internal tangents between two disjoint circles. The following method uses vector and trigonometric expressions.
Consider a point $P(t)$ on the second circle, it is given by
$ P(t) = C_2 + r_2 (\cos t , \sin t ) $
The vector $(\cos t, \sin t)$ is a vector that is perpendicular to the tangent line to the circle at $P(t)$. It is pointing outward of the circle. The equation of the tangent line at $P(t)$ is,
$ (\cos t, \sin t ) \cdot ( (x, y) - P(t) ) = 0 $
We want the (signed) distance between the center of the first circle and this tangent line to be $r_1$. Hence,
$r_1 = (\cos t , \sin t ) \cdot ( C_1 - P(t) ) $
Substitute $P(t)$, you get
$ r_1 = (\cos t, \sin t ) \cdot (C_1 - C_2 - r_2 (\cos t, \sin t) )$
This simplifies to
$ r_1 = (\cos t, \sin t ) \cdot ( C_1 - C_2 ) - r_2 $
Therefore, we want to solve
$ (\cos t , \sin t ) \cdot (C_1 - C_2) = r_1 + r_2 $
If $ V = (V_x, V_y) = C_1 - C_2 $
Then
$V_x \cos t + V_y \sin t = r_1 + r_2 $
There are two solutions to this trigonometric equation, and they are given by
$ t = ATAN2( V_x, V_y ) \pm \cos^{-1} \left( \dfrac{ r_1 + r_2 }{ \sqrt{V_x^2 + V_y^2} } \right) $
The $ATAN2$ function is a standard math library function, and returns the angle $t$, which is the angle between the positive $x$ axis and the line segment extending from $(0,0)$ to $(V_x, V_y)$.
We now have two values of $t$ obtained from the above formula, so we have the equations of the two tangents.
Next, starting from $P(t)$ (where $t$ is one of the two values obtained above), we want to determine which way to move along the tangent line to meet the first circle. To do that, rotate the normal vector which is $(\cos t, \sin t)$ by $90^\circ$ counter clockwise to obtain $d(t) = (-\sin t , \cos t )$. To determine where this is the right direction to move (along the tangent line from the the second circle (B) to the first circle (A) ), calculate
$ d(t) \cdot (C_1 - C_2 ) $
if this is positive, then $d(t)$ is the right direction, otherwise we have to reverse its direction.
Now you can intersect the tangent line
$Q(s) = P(t) + s d(t) , \ s \ge 0 $
with the borders of the bounding rectangle. There are four sides whose cartesian equations are known. Substitute $Q(s)$ into the equation of each border , and solve for $s$. If $s$ is negative then discard that intersection.
In addition, you need the touching points between the tangent lines and the first circle (circle A). This distance $s$ along the direction $d(t)$ is given by
$ s = (C_1 - C_2) \cdot d(t) $
(Projection of the vector $(C_1 - C_2)$ along the unit vector $d(t)$).
Finally you want to add the corner points. To choose which corner point to include in the set of vertices of the polygon, let $E$ be a corner point, then compute the following
$ (E - P(t) ) \cdot (\cos t , \sin t ) $
If $E$ is to be included, then this quantity must be positive for both values of $t$.