Let's consider the following equation:
$$R = \frac{p D\cos\theta}{p - D \sin\theta}$$
Where $R,p,D>0$ and $-\pi/2\le\theta\le0$.
The goal is to transform this formula in order to write something like $\theta = f(R,p,D)$
My first try was to write the equation like below:
$$Rp = D(p\cos\theta + R\sin\theta)$$
Then considering the case where $p=R$, I was able to do this:
\begin{align} R & = D(\cos\theta + \sin\theta) \\ & = D\sqrt{2}[\sin(\pi/4)\cos\theta + \cos(\pi/4)\sin\theta] \\ & = D\sqrt{2}\sin(\pi/4 + \theta) \\ \theta& = \sin^{-1}\left(\frac{R}{D\sqrt{2}}\right) - \frac{\pi}{4} \\ \end{align}
I can do the same considering the angles $\pi/3$ and $\pi/6$ but in all the cases I had to fix the relation between $p$ and $R$ which is not what I want.
I also tried to use the following equation:
$\cos(x)=\frac{1-t^2}{1+t^2}$ , $\sin(x)=\frac{2t}{1+t^2}$ where $t = \tan(\frac{x}{2})$
I ended with a second degree equation
$$(\frac{R}{D} - 1)t^2 - 2\frac{R}{p}t + (\frac{R}{D} - 1) = 0$$
I calculated the solution but I obtained wrong values when testing with the initial formula. probably I missing something on the road.
Is there a magic step or an equation that can help me find $\theta = f(R,p,D)$?
For the reference, this question is a extension of my answer in StakOverflow and below is the figure from where the initial equation was extracted. Probably I didn't extract the good equation and there is a better one that suits my needs.
