Problem with triangles and lots on unknown This problem feel more complicated to me than usual. I am currently stuck with finding some values in the following case.

Here the image illustrate the basic of the problem. What the rules are :

*

*A and B are always on the orange axis

*AB,DE and CE are of known length

*ABF, ADB and BEC are 90 degree

*BF is infinite in that direction

What i need to find is what angle will make BF coincide with C ?
By making BF falling down, A move up a bit while B goes toward the left so that make 2 unknowns that for some reason confuse me too much.
You can see the problem as ABF is a partial drawing of a book on angle in a shelf and the orange lines are the side and bottom of the shelf. The book as to touch the side and bottom and i need to know the angle it hold on the vertical toothpick CE
I am a developer so my current solution is to iterate increasing the length of AD and calculating the triangle of ADB and since ABF is also square i have the triangle BEF and F being infinite i get a point perfect inline with CE finally i can check if my F is higher than C if yes bring up A again a bit more and test until F is below C and get somewhere close to the real answer.
There must be a better way to calculate this.
 A: You're correct that there's a better way. However, first note you could more simply, and I believe also easily, explain your goal by stating that with $AB$ being a fixed length, you're trying to determine the position of $B$ on $DE$ so that $AB$ and $BC$ are perpendicular to each other. Thus, this would be equivalent to $C$ and $F$ coinciding. The diagram below shows this, along with a few specified lengths and angles:

In particular, as you stated, $|AB| = a$, $|CE| = b$ and $|DE| = c$ are given. Also, set $|DB| = d$ (so $|BE| = c - d$) and $|AD| = e$ as unknown values.
With $\measuredangle ABD = x$ and $\measuredangle BAD = y$, we have $x + y = 90^{\circ}$. Thus, $\measuredangle CBE = 180^{\circ} - 90^{\circ} - x = 90^{\circ} - x = y$, so $\measuredangle BCE = x$. This means $\triangle ADB \sim \triangle BEC$, as indicated in Sai Mehta's comment.
Next, as suggested by donaastor's comment, using the relations among the similar triangles, plus the Pythagorean theorem, results in a system of several equations, which can be reduced to a polynomial in one of the unknown values. First, the Pythagorean theorem with $\triangle ADB$ gives that
$$d^2 + e^2 = a^2 \tag{1}\label{eq1A}$$
Next, using that $\triangle ADB \sim \triangle BEC$, we get
$$\frac{e}{d} = \frac{c-d}{b} \; \; \to \; \; \; e = \left(\frac{c-d}{b}\right)d \tag{2}\label{eq2A}$$
Substituting this into \eqref{eq1A} results in
$$\begin{equation}\begin{aligned}
d^2 + \left(\left(\frac{c-d}{b}\right)d\right)^2 & = a^2 \\
(b^2)d^2 + (c-d)^2 d^2 & = a^2(b^2) \\
(b^2)d^2 + (c^2)d^2 - (2c)d^3 + d^4 & = a^2(b^2) \\
d^4 - (2c)d^3 + (b^2 + c^2)d^2 - a^2(b^2) & = 0
\end{aligned}\end{equation}\tag{3}\label{eq3A}$$
Since $a$, $b$ and $c$ are given, this is a quartic equation in the variable $d$. Although \eqref{eq3A} can be solved analytically, as shown in the Wikipedia article, it's usually solved numerically instead, e.g., such as by using the Durand–Kerner method that's also suggested in the article. However, I believe basically all programming languages have either built-in functionality or third-party libraries you can use instead to find the roots (e.g., in Python, there's numpy.roots).
Regardless of how you solve \eqref{eq3A}, with $d$ determined, then $y$ can be calculated in several ways, e.g., by
$$\sin(y) = \frac{d}{a} \; \; \; \to \; \; \; y = \arcsin\left(\frac{d}{a}\right) \tag{4}\label{eq4A}$$
However, especially if you try to solve this with your own code, be careful since quartic equations always have $4$ roots (due to the Fundamental theorem of algebra). I believe there'll usually be $2$ complex conjugates, with the other $2$ being real roots. You want the one with $0 \lt d \lt c$, with the other one being negative, i.e., with $B$ to the left of $D$ (and $A$ below $D$), as shown below:

From \eqref{eq2A}, we then also have that $e \lt 0$, as the diagram above indicates as well.
I assume you always want $B$ to be between $D$ and $E$. If so, especially if you're using your own root-finding method, you should try to ensure you get the correct root (e.g., by choosing an appropriate starting value) or, at the least, add appropriate checking and handling in case you get an out of bound root (i.e., $d \le 0$ or $d \ge c$) instead.
