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