Let the positive x-axis be to the left.

The top of the screen is at $p_{t}=(0,30)$

The bottom of the screen at $p_{b}=(0,8)$

A point on the sloped line at distance $x$ from the screen is at $p=(x, x\tan(8^\circ))$

A vector from the point $p$ to the top of the screen is $v_t=p_t-p=(-x,30-x\tan(8^\circ))$

A vector from the point $p$ to the bottom of the screen is $v_b=p_b - p = (-x, 8-x\tan(8^\circ))$

The angle between these two vectors is $\theta = \arccos\left(\dfrac{v_t \cdot v_b}{|v_t||v_b|}\right)$

This produces different results than your formula.

Rewrite your program to perform the above.