[Math] Calculate after how many bounces screen saver logo will hit a corners

geometry

I've always wondered if it is possible to calculate the number of bounces until the screen saver logo hit both sides of a tv at the same time? Or if it will hit at all?

enter image description here

Assuming that we know: The logos dimensions, it's starting position, angle of movement and the tv dimensions. Also assuming that after a bounce the ball leaves the wall with the same angle (just like light and mirror).

This is just a curiosity so I can know the limits of mathematics.

Best Answer

Basic approach. Imagine an infinite grid. An imaginary ball, corresponding to the real ball on your screen, starts in the unit square. It starts moving in some direction and continues moving forever in that direction.

When it passes a line of the form $x = j$, where $j$ is an integer, that corresponds to the real ball bouncing off either the left or the right side of the screen. When it passes a line of the form $y = k$, where $k$ is an integer, that corresponds to the real ball bouncing off either the upper or the lower side of the screen.

The imaginary ball always moves in the same direction, but the real ball, of course, changes direction each time it passes one of these integer lines.

However, the moments at which the imaginary ball encounters a corner of the form $(j, k)$, where $j$ and $k$ are both integers, correspond to those moments when the real ball hits a corner as well. So the question is, given an initial starting point $(x_0, y_0)$ and a velocity vector $(v_x, v_y)$, if the line

$$ \frac{y-y_0}{v_y} = \frac{x-x_0}{v_x} $$

has an integer solution. If so, the displacement between the initial point $(x_0, y_0)$ and the solution point $(j, k)$, along with the component velocities $v_x$ and $v_y$ will tell you how long it takes to get there.

I'll try to add more about this problem when I get more time.