General Mathematics

A Python project I did while bored one day.

The original intent was to have the output be the final animated gif file, but I never finished that aspect and just used GIMP to compile the stills.

The idea was just to have sine waves that emanated from given points and be able to accurately display the waves and in the case of multiple origins, the interference patterns.

Just think of them as being seen from above, white being crests and black being troughs.  Now, this was around the same time as the Voronoi images so no surprise that different metrics where on my mind.  I did the normal Euclidean distance but also threw in my favourite alternate metric, Manhattan distance.

So, some typical examples follow.  These are the same sine waves, same amplitude, frequency and velocity, just different metrics.

Single origin, Euclidean distance sine wave. No drop off of amplitude here or in any of the animations shown below, although the software was capable of it. Basically you have expanding concentric circles here, nothing mind blowing.Single origin, Euclidean distance sine wave.
Single origin, Manhattan distance sine wave. This is the same origin point, same frequency, amplitude and velocity, only the distance metric changes. Expanding concentric diamonds (or squares if you don't think standing a square on a point changes anything about it) replace the circles, but of the same thickness etc. A little neat, but nothing to write home about.Single origin Manhattan distance sine wave
Dual origin, Euclidean distance sine waves, interfering. The two wave generators are producing waves of identical frequency, amplitude and velocity. A nice interference pattern looking exactly as one would expect.Dual origin, Manhattan distance sine waves interfering
Dual origin, Manhattan distance sine waves, interfering. So, this has the same origin points, same frequency, amplitude and velocity as the one just above, but Manhattan distance is used instead of the normal Euclidean distance. This is the exact same interference pattern as the one just above, but because of how the distance is calculated, we get this really neat patchwork effect. I discuss just a few of the key features after the cut.Dual origin, Manhattan distance sine waves interfering

Continue Reading

A Voronoi diagram is a visual representation of relative distance between several points on the plane.  For a given point on the plane (in most examples and in my examples below the point is coloured black) a colour is assigned, and all surrounding pixels to that point are coloured the assigned shade if they are closer to that point than to another.  So, as you get further from a point eventually a given pixel is closer to another point than to the one we were first concerned with, and that pixel is coloured the assigned colour of that other point.  So a given pixel is coloured black (usually, but no one can stop you from not doing so if you like) or is coloured the assigned colour of the nearest key point.

So, one can think of the solid colour areas as the area of influence of the point that colour was assigned to that is somewhere within that solid region.  That is one way to think about it, see the wikipedia entry linked above for a far better explaination that I have supplied, along with a partial list of applications of these diagrams.

A while ago a friend of mine was talking about ways to tessellate 2 dimensional images for a certain effect he wanted.  He was talking to me about this and mentioned he thought interpolating a given image as a Voronoi diagram could give him the effect he wanted if consistent reference points and colour mappings were possible.  I wasn’t at the time familiar with these diagrams and read up on them.  The first question was if an original image could be discerned from such a diagram, and I offered to throw together a quick proof of concept program (the friend in question is far and away a better programmer than I am, but I have been doing computer imagery for a long time and I also have a formal mathematics education whereas he does not.  I still am deeply in his debt for his help in many of my projects).

Here is an example of what the first images we produced looked like.Voronoi Map - Euclidean Distance

Continue Reading