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.

 A: Set Cartesian coordinates on the plane so that the center of the circle
is $(0,0)$ and the black line $\overline{AB}$ is parallel to the $x$-axis.
The coordinates of $A$ are $(-(a - b), c)$ and the distance $OA$ is
$\sqrt{(a - b)^2 + c^2}$. Therefore 
\begin{align}
\angle OAB & = \arcsin\left( \frac{\sqrt{(a - b)^2 + c^2}}{c} \right)
= \arctan \left( \frac{c}{a-b} \right) & \text{and} \\
\angle OAQ & = \arcsin\left( \frac{\sqrt{(a - b)^2 + c^2}}{r} \right).
\end{align}
The coordinates of $B$ are $(b, c)$ and the distance $OB$ is
$\sqrt{b^2 + c^2}$, so 
\begin{align}
\angle OBA & = \arcsin\left( \frac{\sqrt{b^2 + c^2}}{c} \right)
= \arctan \left( \frac cb \right) & \text{and} \\
\angle OBP & = \arcsin\left( \frac{\sqrt{b^2 + c^2}}{r} \right).
\end{align}
Since $\angle BAM = \angle OAB + \angle OAQ$
and $\angle ABM = \angle OBA - \angle OBP$,
and $\theta = \pi - \angle BAM - \angle ABM$,
\begin{align}
\theta & = \pi - (\angle OAB + \angle OAQ) - (\angle OBA - \angle OBP) \\
& = \pi - \arctan \frac{c}{a-b}
        - \arcsin \frac{\sqrt{(a - b)^2 + c^2}}{r} 
        - \arctan \frac cb
        + \arcsin \frac{\sqrt{b^2 + c^2}}{r} .
\end{align}

Another approach: consider the figure below, which shows line $\overline{AB}$
and segments  $\overline{OP}$ and $\overline{BP}$. It also shows the
perpendicular from $O$ to $\overline{AB}$, which intersects $\overline{AB}$
at $C$ and $\overline{BP}$ at $R$.

From the original problem statement, we have $OP = r$, $BC = |b|$, and $OC = c$.
Let $OR = |u|$, with $u$ positive if $R$ is between $O$ and $C$ as shown. Then $CR = |c - u|$ and $PR = \sqrt{u^2 - r^2}$, and by similar triangles,
$$ \frac{\sqrt{u^2 - r^2}}{r} = \pm\frac{c - u}{b}.$$
There are actually three cases represented here:


*

*$b > 0$, shown in the figure;

*$-r < b < 0$, in which case $R$ is on the extension of $\overline{OC}$ beyond $C$, $u > c$, and $\triangle BCR$ has (positive) leg lengths $-b$ and $u - c$; and

*$b < -r$, in which case $R$ is on the extension of $\overline{OC}$ beyond $O$, $u < -r$, and $\triangle BCR$ has (positive) leg lengths $-b$ and $c - u = c + |u|$. This is the case that requires the "$-$" option of the $\pm$ sign.


In all three cases I assume $c > r$.
Squaring both sides of this equation and rearranging terms appropriately,
we get:
$$ (b^2 - r^2)u^2 + 2cr^2 u - (b^2 + c^2)r^2 = 0.  \tag 1$$
If $b^2 \neq r^2$ this is a quadratic equation in $u$, and it has roots
$$ u = \frac{-cr^2 \pm br \sqrt{b^2 + c^2 - r^2}}{b^2 - r^2}.$$
We want the positive root if $b > -r$ and the negative root if $b < -r$, so
$$ \angle CBP = \arccos \frac ru 
 =
\begin{cases}
\arccos  \dfrac{b^2 - r^2}{-cr + b \sqrt{b^2 + c^2 - r^2}}
 & \text{if $b > r$} \\
\arccos  \dfrac{b^2 - r^2}{-cr - b \sqrt{b^2 + c^2 - r^2}}
 & \text{if $b < r$ and $b \neq -r$.}
\end{cases}$$
But if $b = r$, then
$ u = \dfrac{c^2+r^2}{2 c} $
and
$$ \angle CBP = \arccos \frac ru 
 = \arccos  \frac{2cr}{c^2+r^2} ,$$
whereas if $b = -r$ then $\angle CBP = \frac\pi2$.
And oh, look, all of these formulas apply to $\angle BAQ$ in the original figure
if we substitute $b - a$ for $b$ 
(and $b - a < -r$ provided that $\angle BAQ$ is acute, as shown), so
if we assume $b > -r$,
\begin{align}
\theta & = \pi - \angle BAQ - \angle CBP \\
& \begin{aligned}
      = \pi & - \arccos  \dfrac{(a - b)^2 - r^2}
                               {-cr + (a - b) \sqrt{(a - b)^2 + c^2 - r^2}} \\
            & - \begin{cases}
                 \arccos  \dfrac{b^2 - r^2}{-cr + b \sqrt{b^2 + c^2 - r^2}}
                  & \text{if $b > r$} \\
                 \arccos  \dfrac{b^2 - r^2}{-cr - b \sqrt{b^2 + c^2 - r^2}}
                  & \text{if $-r < b < r$} \\
                 \arccos  \dfrac{2cr}{c^2+r^2} & \text{if $b = r$}
                \end{cases}
  \end{aligned} \\
&  = \arcsin \dfrac{(a - b)^2 - r^2}
                   {-cr + (a - b) \sqrt{(a - b)^2 + c^2 - r^2}} \\
& \qquad\qquad +
  \begin{cases}
    \arcsin  \dfrac{b^2 - r^2}{-cr + b \sqrt{b^2 + c^2 - r^2}}
     & \text{if $b > r$} \\
    \arcsin  \dfrac{b^2 - r^2}{-cr - b \sqrt{b^2 + c^2 - r^2}}
     & \text{if $-r < b < r$} \\
    \arcsin  \dfrac{2cr}{c^2+r^2} & \text{if $b = r$}
  \end{cases}
\end{align}
So that's just two trig functions, though there are three cases depending
on the value of $b$.
As suggested in a comment, we could get this down to one trig function if
we could find the three sides of $\triangle ABM$ without using trigonometry;
but I think this would involve saying something about the triangles
$\triangle OPM$ and $\triangle OQM$, and I do not yet see how to do it. 
A: 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$.
