There is a square with fix lenth(2a). $O$ is the center point of square. $OB$ is an other line which is make a beta angle with $OA$ line. Angle of $OA$ line is changed between $0$ degree to $360$ degree. $C$ is a point in $OA$. But always $OC$ and $BC$ orthogonal and $B$ is going on lines of square. As well as, always I have the value of length of $OC(l)$. I have to find the beta $(AOB)$ angle for some programming step. I have used this trigonometry equation to solve this problem. but some period of the theta angle, giving wrong answers.
$l / \cos (\beta) = a / \sin(\beta + \theta)$
..... .....
$\tan \beta = { (a/l) / \cos \theta - \tan \theta }$

Using arctan(beta), I would use this psuedocode:
You should be aware that if your angle is exactly 90º or 270º ($\frac{\pi}{2}$ or $\frac{3\pi}{2}$), then
arctanis undefined. You should probably catch those cases first.