Angle between segments resting against a circle Motivation:
A couple of days ago, when I was solving this question, I had to consider a configuration like this

Now, I didn't intentionally make those two yellow bars stand at what appears to be a $90^{\circ}$-angle but it struck me as an interesting situation, so much so that I thought the following question might be an interesting one to solve.
The Question:
Given a circle of radius $r$, a horizontal line a distance $c>r$ from the circle's centre, and two points $A$ and $B$ on that line located as indicated in the picture below, find the angle $\Theta$ as a function of the parameters given ($a,b,c,r$). The blue and red lines passing through $M$ are tangents to the circle, at $P$ and $Q$ respectively.


I have a solution of the form $\tan\frac{\theta}{2} = f(a,b,c,r)$.
First, note that $\angle QOM = \angle POM$. This comes from the triangles $OPM$ and $OQM$ being similar. They're both rectangular (at $P$ and $Q$), they share the same hypotenuse ($\overline{OM}$), and $\overline{OP} = \overline{OQ} = r$. This also implies that $\overline{PM} = \overline{QM}$. Let $\xi \equiv \overline{PM}$.
Next, note that $\angle POM = \theta/2$. This results from the above and $\theta + (\pi/2 - \angle POM) + (\pi/2 - \angle QOM) = \pi$.
Next, note that $\tan\left(\angle POM\right) = \overline{PM}/\overline{OP} = \xi/r$, so

$$
\xi = r\tan\frac{\theta}{2}
$$

We'll now seek an equation for $\xi$ in terms of the various parameters of the problem. Note the following relations:
$$
\overline{AM} = \overline{AQ} - \overline{QM} = \overline{AQ} - \xi \qquad (1)
$$
$$
\overline{OA}^{\,2} = \overline{OQ}^{\,2} + \overline{AQ}^{\,2} = r^2 + \overline{AQ}^{\,2}
$$
$$
\overline{OA}^{\,2} = (a-b)^2 + c^2
$$
Similarly,
$$
\overline{BM} = \overline{BP} + \overline{PM} = \overline{BP} + \xi \qquad (2)
$$
$$
\overline{OB}^{\,2} = \overline{OP}^{\,2} + \overline{BP}^{\,2} = r^2 + \overline{BP}^{\,2}
$$
$$
\overline{OB}^{\,2} = b^2 + c^2
$$
Then
$$
\overline{AQ}^{\,2} = (a-b)^2 + c^2 - r^2 \qquad (3)
$$
$$
\overline{BP}^{\,2} = b^2 + c^2 - r^2 \qquad (4)
$$
Now let

$$
u \equiv \overline{AQ} = \sqrt{(a-b)^2 + c^2 - r^2}
\qquad\mbox{and}\qquad
v \equiv \overline{BP} = \sqrt{b^2 + c^2 - r^2}
$$

From (1)-(4) and the law of cosines,
$$
\overline{AB}^{\,2} = \overline{AM}^{\,2} + \overline{BM}^{\,2} - 2\,\overline{AM}\,\overline{BM}\,\cos\theta
\qquad (5)
$$
we see that we'll need $\cos\theta$ in terms of $\tan\frac{\theta}{2}$. That's easy:
$$
\cos\theta = \frac{1 - \tan^2\frac{\theta}{2}}{1 + \tan^2\frac{\theta}{2}} = \frac{r^2 - \xi^2}{r^2 + \xi^2}
\qquad (6)
$$
Combining all of the above, we can get a quadratic equation for $\xi$, after some tedius but not particularly difficult algebra:
$$
\left[ (u+v)^2 + 4r^2 - a^2 \right] \xi^2 - 4(u-v)r^2\,\xi + \left[ (u-v)^2 - a^2 \right] r^2 = 0
$$
whose solution is
$$
\frac{\xi}{r} =
\frac{2(u-v)r \pm \sqrt{
4(u-v)^2r^2 - \left[ (u+v)^2 + 4r^2 - a^2 \right] \left[ (u-v)^2 - a^2 \right]
}}{\left[ (u+v)^2 + 4r^2 - a^2 \right]}
$$
The second term inside the radical, sans the negative sign, simplifies to
$$
\left[ (u+v)^2 + 4r^2 - a^2 \right] \left[ (u-v)^2 - a^2 \right] =
4r^2(u-v)^2-4a^2c^2
$$
and we find
$$
\frac{\xi}{2r} =
\frac{(u-v)r \pm ac}{\left[ (u+v)^2 + 4r^2 - a^2 \right]}
$$
Thus,

$$
\tan\frac{\theta}{2} =
\frac{2\left[ (u-v)r \pm ac \right]}{\left[ (u+v)^2 + 4r^2 - a^2 \right]}
$$
  where
  $$
u \equiv \overline{AQ} = \sqrt{(a-b)^2 + c^2 - r^2}
\qquad\mbox{and}\qquad
v \equiv \overline{BP} = \sqrt{b^2 + c^2 - r^2}
$$

It's not surprising that there should be two valid solutions, since $Q$ could also be on the side closer to $B$.
