Line with predefined length tangent to circle I have one math problem which I'm trying to solve. I know it could be done but I'm a little bit "rusty" with my algebra. I'm kindly asking for help.
Problem and procedure of my solution are shown in attached image. I'm trying to find general solution for line equation (points $1$ and $2$ lie on this line) which is tangent to circle with radius $R$ and center point in $(0,a)$. Length $L$ of line from point $1$ to point $2$ is also known.
Basically I'm searching for coordinates of points $1$ and $2$ with $y_2=0$. I think that for $L>a$ there should be 4 possible solutions. I'm only interested in one which has $x_1>0$ and $x_2>0$.
I have $4$ equations, which should be enough for solving this system, but it gets complicated. Maybe someone has some pointers or is there an easier way to do it?

 A: Here's a partial answer: recall that a tangent to a circle at $T$ from an external point $P$ is perpendicular to the radius at $T$. So using the Pythagorean Theorem,
\begin{equation*}
  R^2+L^2 = d((x_2,0),(0,a))^2 = x_2^2 + a^2,
\end{equation*}
so that since you want $x_2>0$ we get $x_2 = \sqrt{R^2+L^2-a^2}$.
Note that while there are four solutions, there are only two possible values of $x_2$, since the two tangents from any external point to a circle have equal lengths.
Next, solve $x_1^2 + (y_1-a)^2 = r^2$ for $y_1$, giving $y_1 = a\pm\sqrt{r^2-x_1^2}$; again take the positive square root. Using the equation for the length of the tangent, we get
\begin{equation*}
  (x_1-\sqrt{l^2+r^2-a^2})^2 + (a+\sqrt{r^2-x_1^2})^2 = l^2,
\end{equation*}
or
\begin{equation*}
  (r^2+l^2)x_1^2 - 2r^2\sqrt{l^2+r^2-a^2}\,x_1 + r^4 - a^2r^2 = 0.
\end{equation*}
Solving the quadratic for $x_1$ gives
\begin{equation*}
  x_1 = \frac{arl+r^2\sqrt{l^2+r^2-a^2}}{l^2+r^2}.
\end{equation*}
I don't see a simple way yet to derive $y_1$ from this, but the answer is
\begin{equation*}
  y_1 = \frac{l}{r}x_1 = \frac{l(al+r\sqrt{l^2+r^2-a^2})}{l^2+r^2}.
\end{equation*}
