Fun with interference patterns

Ordinary trigonometric functions can produce really interesting, structured patterns if you use sufficiently large numbers. There’s nothing fancy happening here, but at different scales and with different constants, the result can change quite drastically. Try zooming in (z = z * 0.01 for instance) and you’ll see that it’s just bands of white and black. It’s only when you zoom out that creeping bands moving in crazy directions appear.

I’m fairly sure this is a straightforward consequence of interference. The square grid of pixels is sampling the underlying equation at regular intervals. The result is a kind of moirĂ© pattern. For photography and graphics applications aliasing is Bad News, but you can harness it to produce interesting patterns.

Anyway, math aside, you can pretty much just start messing with constants and mushing trigonometric functions together here and see what happens. It inherits some of the rotational symmetry of the underlying pattern, so we end up with something that isn’t completely mush. Plugging the time variable into a periodic function like sin lets us quite easily find interesting loops, ripe for the giffing.

My current “fancy” way to gif something is to render it in Fragmentarium and take the resulting pngs and run them through ImageMagick’s convert utility. This is a bit fiddly, so often I just use my favorite program: GifCam! It’s a tiny utility that records gifs directly off your screen. It certainly won’t produce the best, smallest, lowest-artifact gif, but it’s easy to use and the results aren’t half bad!

Next: Drawing fractal Droste images >
< Previous: Recreating the Doctor Who Time Tunnel in GLSL