# Polygonal billards programs

I'm looking for software that will give billiard trajectories in arbitrary plane polygons. After much work I was able to produce this figure.

It was a good exercise, but at this point I wonder if scripts already exist.

I've heard if the angles are rational multiples of pi you can unfold the polygon so the billiard flow in the polygon becomes the geodesic flow on a translation surface.

-
It's not quite what you want, but you might be interested in McBilliards : mcbilliards.sourceforge.net –  Andy Putman Aug 3 '10 at 3:32
Richard Schwartz (webpage here : math.brown.edu/~res ) has done an enormous amount of computer-aided investigations of billiards. You might want to look at his webpage and possibly contact him -- he would certainly know if anything like this exists. –  Andy Putman Aug 3 '10 at 3:37
On top of what Andy says, let me add that Rich is extremely amiable and helpful, and you shouldn't hesitate to contact him. :) –  David Hansen Aug 3 '10 at 3:53
Like many others, I also have implemented billiards programs, but my code is ad hoc rather than a general script. I would like to offer one caveat: it is challenging to control the numerical errors. After a large number of reflections, the results can easily become random nonsense. –  Joseph O'Rourke Aug 3 '10 at 12:26
@John Mangual: It depends on what you seek to learn from your simulation. A billiard ball shot off at a rational multiple of $\pi$ angle behaves rather differently than does one shot at an irrational angle. And with standard computer arithmetic, your billiards are all shot at rational angles. If either what you care about does not depend on the rational/irrational distinction, or you don't run your simulation long enough to reach the end of your bit precision, then numerical issues are not relevant. Otherwise they are. –  Joseph O'Rourke Aug 3 '10 at 16:22