GithubHelp home page GithubHelp logo

interference-simulation's Introduction

Interference-Simulation

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:

, where:

  • 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:

Time Scale

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.

Demo

Watch on YouTube: https://www.youtube.com/watch?v=CgBImdjw3hc

Interference Demo Video

interference-simulation's People

Contributors

tomnwright avatar

Watchers

James Cloos avatar

interference-simulation's Issues

Phase Change

Add in phase change from non-transformed wave (all waves with same wavelength are currently coherent)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.