As you can see in the above picture, suppose that there is a ray emitted from center which intersects the edge of the rectangle.
How do I calculate at which point the ray intersects the edge?
(So that I could be able to calculate the distance between the center and a point on the edge.)
The following is known:
- width and height of rectangle
- a degree & b degree (as shown in above figure)
- centerX, centerY

if you only need distance then,
$$\cos b^{\circ} = {\text{half width}\over \text {distance you want to find} }$$
The slope of line $A$ is $0$.
let the slope of red line be $m$.
$$\tan a^{\circ} = {|0 - m| \over |1+ 0*m|} = |m|$$
you now know the slope of the red line and one point on it. Can you find the $(x2 , y2)$ now ?