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.