Artificial intelligent assistant

Formula for refraction between two mirrors i have a question about refraction. A light beam is sent diagonally into two parallel mirrors. Now i want to get the distance y depending on x. Is there a general formula ? In my example the two parallels are always 60 units apart, but the angle of the input ray is variable. Also, if there is no formula, is there any way to solve this problem programmatically? !enter image description here Thanks

Let $\theta$ be the positive angle between the ray and the $x$-axis. Let $h$ be the distance between the two mirrors. In this case, $h=60$.

Let $d$ be the horizontal distance travelled by the ray in going (once) from one mirror to the other mirror. Then, $$d = \dfrac{h}{\tan{\theta}}.$$

With $y=f(x)$ as the required function,

$$f(x) = \begin{cases} h - \left(x - \left\lfloor \frac{x}{d} \right\rfloor d\right)\tan{\theta}, & \text{if $\left\lfloor \frac{x}{d} \right\rfloor$ is even (ray is going down)} \\\ \left(x - \left\lfloor \frac{x}{d} \right\rfloor d\right)\tan{\theta}, & \text{if $\left\lfloor \frac{x}{d} \right\rfloor$ is odd (ray is going up).} \end{cases} $$

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 9e275ec15ef526e9b5410002a44218ac