find angle in square which is added for variable angle of center

65 Views Asked by At

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 }$

enter image description here

1

There are 1 best solutions below

0
On

Using arctan(beta), I would use this psuedocode:

if( beta > (3*π)/2 )
    beta = beta - 2*π
else if( beta > π/2 ) 
    beta = beta - π

answer = arctan(beta)

You should be aware that if your angle is exactly 90º or 270º ($\frac{\pi}{2}$ or $\frac{3\pi}{2}$), then arctan is undefined. You should probably catch those cases first.