Monday, February 6, 2012

bouncing dot analysis

I made a "level" comprised of walls that are either vertical, horizontal or halfway in between. Then you put a point in the level and it can move in one of the basic eight directions one pixel at a time. Then it bounces off the walls like so:
You can see it gets back to the original point moving in the same direction and then it repeats about every 30 seconds.  A little bit of analysis shows that what actually happens is there are two points in the pattern where the point completely reverses direction. And a bit of thought can deduce that a necessary condition for that to happen is two walls that can be connected by an uninterrupted line of possible point travel are aligned 45 degrees apart. By the way this video is 5000 frames long. 
   So you can design a level without that necessary condition, one easy way is to avoid diagonal lines in the level altogether so all the levels walls can only be increments of 90 degrees apart. Though I found you have to delete the very corner pixel of each rectangle when using my bouncing algorithm. 

In this 5000 frames of video the position and velocity of the point never repeats. It's easy to tell because around 3 minutes in the point eventually squeezed between the top left block and the wall and it never had before that.
  So a good question might be how long it would take to repeat a position moving in the same direction. If I find out I'll update this blog entry.

No comments:

Post a Comment