Geometry/Trigonometry of a Simple Model In the image below, I am trying to write $x'$ in terms of $r_1, r_2, \theta_1, \theta_2,$ and $x$. 
We know that $\theta_1, \theta_2 \in [0,\pi)$ and $r_1, r_2, x > 0$.
I have tried all the tricks I know but I cannot figure it out. Any hints or help is much appreciated.

 A: Hint: Rotate/translate the points so the point with $\theta_2$ lies at the origin and the point with $\theta_1$ lies at $(x,0)$. Then we can find coordinates for the two endpoints, and from there get $x'$ by the Pythagorean theorem.
A: Let $a$ the lenght of the common side of triangles with sides $r_1,r_2,x,x'$ (the opposite to $\theta_1$). By cosine rule, we have:
$$a=\sqrt{x^2+r_1^2-2x r_1 \cos(\theta_1)}$$
Let $\theta_3$ the opposite angle to $r_1$. By sine rule, we have:
$$\frac{a}{\sin(\theta_1)}=\frac{r_1}{\sin(\theta_3)} \leftrightarrow \theta_3=\sin^{-1}\left(\frac{r_1\sin(\theta_1)}{\sqrt{x^2+r_1^2-2x r_1 \cos(\theta_1)}}\right)$$
Note that being $\theta_3\in (0,\pi]$, we don't have to consider $\sin^{-1}$ negative an then add $\pi$. Now, we apply again cosine rule, arriving at:
$$x'=\sqrt{a^2+r_2^2-2a r_2 \cos(\theta_2+\theta_3)}=\sqrt{x^2+r_1^2-2x r_1 \cos(\theta_1)+r_2^2-2\sqrt{x^2+r_1^2-2x r_1 \cos(\theta_1)} r_2 \cos\left(\theta_2+\sin^{-1}\left(\frac{r_1\sin(\theta_1)}{\sqrt{x^2+r_1^2-2x r_1 \cos(\theta_1)}}\right)\right)}$$
