Does a screen saver have to repeat its motion?

82 Views Asked by At

Suppose we have an $n$ x $m$ grid, and an object situated in that grid at position $(x,y)$ of size $1$ x $1$ with an initial vector (direction) $v$.

Would this object necessarily repeat its motion or stated another way does it have always have to have a period?

We can assume when the object hits an edge it is reflected.

EDIT: I have perhaps emphasized the real world aspect of this question too much. Let me make this clearer

  • We should not concern ourselves with the computer internals (memory, how the $n$ x $m$ grid is displayed)

  • The intial $(x,y)$ position does not need to be composed of integers (or indeed rationals)

  • The direction must be rectilinear

1

There are 1 best solutions below

2
On

As you store the state of your screensaver digitally with bits and bytes, it can only have $2^n$ possible states, where $n$ is the number of bits needed to represent its state. Thus after $2^n$ steps (or earlier), it must to repeat. Of course, if its state is sufficiently complex, this will take a long time.

However, if I understand your scenario correctly, it will repeat much earlier:

  • As your object is reflected perfectly by perpendicular walls, it can only have four possible directions (whatever you can obtain by mirroring the direction vector on the coordinate axes).
  • Also, your object can only have as many possible locations as there are pixels on your screen.

For example, on a 1024×768 screen, the motion has to repeat every $4·1024·768 = 3145728$ steps. If you have 10 steps per second, this would be every 87 hours.