Interference Patterns

When you drop a rock into a pond, ripples spread outward from the point of impact as circular waves. (Well, not perfectly circular, but close enough for our purposes…) If you drop two rocks in at different points, the two sets of waves will overlap, creating new and more complicated ripple, or wave, patterns. This is known as interference.

Now, take this basic idea and transfer it into a computer program. Throw in some color, add some more “point sources”, and suspend some real world assumptions (such as diminishing amplitude). In this way you can produce some beautiful or interesting digital images.

2015-12-08-193658_800x600_scrot

If you put several of these wave sources in a circle, and provide a fine grain “resolution” (that is, short wavelengths on the screen), geometric themes appear. Triangles, squares, hexagons, and so forth.

If we add more sources, our images tend to get more detailed and decorative.

One nice thing about creating our interference patterns inside of a computer program, is that we can easily adjust the fundamental mathematics involved. For example, the program uses a function to determine the distance between two points, known as a “metric”. We naturally code in the Euclidean metric, which equals the length of a straight line between the two points. Alternatively, we can choose the Manhattan metric, which calculates as though distance can only be transversed in a north-south or east-west direction, like a taxi-cab driver navigating the blocks of downtown Manhattan. Using this function, our images have a markedly different character:

manh-00

Or let’s do something a little more strange, getting the square root of the original Euclidean metric:

interference12

Another interesting metric is to apply a recursive folding function over the Euclidean and Manhattan metrics:

foldAdj :: Float -> Float -> Float -> Float
foldAdj base ffactor uval = foldAdj' base uval 0
  where foldAdj' stepv remv cumv =
          if remv - base <= 0
          then cumv + stepv * remv / base
          else foldAdj' (stepv * ffactor) (remv - base) (cumv + stepv)

The program used to produce the images in this particular gallery has not yet been released to the public. However, it is written in the Haskell programming language and utilizes the Gloss module to display the images.