Simulation of the interference pattern between n coherent1 sources. Each source is assigned a pixel location. Then, for each pixel, the distance from that pixel to each source is calculated and used to calculate the amplitude of the wave from each source. These amplitudes are added to find the superposition of all waves at that point. A separate function interpolates between blue (-1), white (0), and red (+1), and is used to assign each pixel a colour based on its wave superposition. Wave functions return between -1 (trough) and +1 (peak), but the superposition of these waves may exceed this range.
The amplitude, I, of the wave from each source at a given pixel is calculated as a function of the distance of that pixel to the source. For source A:
This produces a wave with a wavelength of . Therefore scaling the function along the d axis by a factor of
, where s is the number of pixels per unit distance (pixel scale), produces a wave with a wavelength of s px:
Next the wave is translated along the x axis as a function of the amount of time which has passed, allowing animation. If the wave moves along the d axis at a rate of one wavelength per second, then its dispacement, k is given as:
- t is time in frames, and f is video frame rate.
- p is phase, as a fraction of wavelength
Also, k gives the leading edge of the wave, allowing restriction of the wave domains:
The value above, is in terms of video seconds. However, if the waves are assumed to be sound in air, an absolute time value can be calculated. In one video second, the wave travels 1 wavelength. The speed of sound in air is 343 ms-1. Therefore, the sound wave takes
virtual seconds to travel that one wavelength, 1m (only if
). Therefore, 1 video second (25 frames) =
virtual seconds.
Watch on YouTube: https://www.youtube.com/watch?v=CgBImdjw3hc