A web app to easily simulate 2D waves in your browser.

Overview

Wave Simulator

Wave Simulator is a web app that allows to simulate 2D waves in your browser.
Simply choose a background image, a color gradient and tweak the different parameters, then start the simulation and let the app simulate the wave.

lens.mp4
lens double slit
ellipse parabolla

The simulation is done by numerically solving the wave equation:

$\nabla^2u - \frac{1}{c^2}\frac{\partial^2u}{\partial t^2} = 0$

where u is the wave function.

It uses this formula to compute the second deriviative:

$f''(x) \approx \frac{f(x+h) - 2 f(x) + f(x-h)}{h^{2}}$

The simulation is performed on every pixel at each frame using WebGL: a JavaScript API for GPU-accelerated processing.


The following is the documentation of Wave Simulator:

Background image

This image defines the behaviour of the wave throughout the canvas. At any given point, if the alpha value is greater than the alpha threshold, the value is set to zero (acting like a wall). Otherwise, if the alpha value is smaller than the alpha threshold, the alpha value dictates the speed of the wave. For example, if the alpha value of a pixel is 0.5 and the alpha threshold is 1.0, the wave will be 2 times slower in that pixel.
This image can be created using a vector graphics software.

  • Download an example image: click on Background > File > Download Example
  • Use your own files: click on Background > File > Open

Gradient image

This image defines the color of the simulated wave. The color is read from top to bottom.
If average energy is set to false, the range is -1.0 to 1.0,
Otherwise, if average energy is set to true, the range is 0.0 to 1.0

  • Download an example image: click on Gradient > File > Download Example
  • Use your own files: click on Gradient > File > Open

Average energy

This checkbox controls whether the app displays the value of the wave or the average energy carried by the wave (average of its squared value).

Boundary conditions

It controls the way the wave interacts with the boundary of the canvas by setting a virtual value outside the canvas.

Condition Virtual value
Absorb equal to the previous value of the wave at the neighbour pixel
Reflect equal to the value of the wave at the neighbour pixel
Zero 0.0

Alpha threshold

This slider controls the alpha threshold, i.e. any pixel with an alpha value greater than this is considered a wall.
This can prevent antialiasing on images to cause unwanted behaviour such as the wave looking like it's emitted from a wall (see video bellow).

antialiasing.problem.mp4

Keep aspect ratio

This checkbox controls whether the simulation canvas keeps the same aspect ratio as the background image.

Show gradient legend

This checkbox controls whether the gradient legend is shown on the bottom right of the canvas.

Level of detail

It controls the pixel density of the simulation, i.e. the size of a simulation pixel compared to the background image pixels.
This parameter is only available on desktop (not mobile).

LOD simulation pixels per background pixel
High 1
Medium 2
Low 2.8

Speed

Controls the speed of the simulation (by skipping frames).

Speed frames skipped
Max O
Medium 3
Slow 8

Initial conditions

Defines the way the wave is created. There are four types:

Plane wave This creates a sinusoidal plane wave by forcing the edge pixels to have an oscillating value.

Direction

Controls the edge from which the wave comes from.

Duration

Controls the duration of the oscillation, in frames.

Frequency

Controls the frequency of the oscillation.

Amplitude

Controls the amplitude of the oscillation.

Pulse This creates a pulse by setting the value of the wave at frame zero to a Gaussian function.

Shape

Controls the shape of the pulse:

  • Circular: the Gaussian function depends on the distance to the center
  • Vertical: the Gaussian function depends on the x position of the pixel
  • Horizontal: the Gaussian function depends on the y position of the pixel

Position

Controls the position of the center of the Gaussian function.
(x, y) = (0.0, 0.0) is bottom left.
(x, y) = (1.0, 1.0) is top right.

Amplitude

Controls the amplitude of the Gaussian function.

Frequency

Controls how much the Gaussian function is spread. Higher value results in a less spread wave.

Spherical wave This creates a sinusoidal spherical wave by forcing the center pixel to have an oscillating value.

Position

Controls the position of the center pixel.
(x, y) = (0.0, 0.0) is bottom left.
(x, y) = (1.0, 1.0) is top right.

Duration

Controls the duration of the oscillation, in frames.

Frequency

Controls the frequency of the oscillation.

Amplitude

Controls the amplitude of the oscillation.

Interactive pulse This adds a pulse to the wave where you click. A pulse is a Gaussian function shaped wave.

Shape

Controls the shape of the pulse:

  • Circular: the Gaussian function depends on the distance to the click
  • Vertical: the Gaussian function depends on the x position of the pixel
  • Horizontal: the Gaussian function depends on the y position of the pixel

Amplitude

Controls the amplitude of the Gaussian function.

Frequency

Controls how much the Gaussian function is spread. Higher value results in a less spread wave.

You might also like...

Easily add aspect ratio in your Solid app.

Easily add aspect ratio in your Solid app.

Creates a component with a proportional relationship between its width and height. ratio = width / height Table of Contents Demo Installation Setup Us

Nov 4, 2022

Seamlessly connect your web server to Rebrandly so that you can re-use your domain name for both your app and your short links

rebrandly-express Seamlessly connect your web server to Rebrandly so that you can re-use your domain name for both your app and your short links Rebra

Dec 13, 2022

mirrord lets you easily mirror traffic from your production environment to your development environment.

mirrord lets you easily mirror traffic from your production environment to your development environment.

mirrord lets you easily mirror traffic from your Kubernetes cluster to your development environment. It comes as both Visual Studio Code extension and a CLI tool.

Dec 24, 2022

Persistent key/value data storage for your Browser and/or PWA, promisified, including file support and service worker support, all with IndexedDB. Perfectly suitable for your next (PWA) app.

Persistent key/value data storage for your Browser and/or PWA, promisified, including file support and service worker support, all with IndexedDB. Perfectly suitable for your next (PWA) app.

BrowstorJS 🚀 💾 🔒 Persistent key/value data storage for your Browser and/or PWA, promisified, including file support and service worker support, all

Aug 5, 2022

Open source app to beautify screenshots, quickly and easily

Codename: Pika What it does Lets you quickly beautify screenshots by adding rounded corners, background colors, shadows and more. You can copy the bea

Dec 29, 2022

A minimalist ToDo list app to add, update and remove tasks easily

A minimalist ToDo list app to add, update and remove tasks easily

To-do list is a tool that helps to organize your day. It simply lists the things that you need to do and allows you to mark them as complete. We will build a simple website that allows for doing that, and we will do it using ES6 and Webpack!

Jun 23, 2022

Obsidian Web: Connect your browser with your Obsidian notes

 Obsidian Web: Connect your browser with your Obsidian notes

Obsidian Web: Connect your browser with your Obsidian notes This is an unofficial Chrome extension for Obsidian that lets you send content from the we

Jan 3, 2023

The browser (chrome/firefox) extension that hides annoying login pop-ups in the Twitter web app

The browser (chrome/firefox) extension that hides annoying login pop-ups in the Twitter web app

The browser (chrome/firefox) extension that hides annoying login pop-ups in the Twitter web app

Dec 6, 2022
A simple waves effect library

jquery-waves A simple & lightweight waves effect plugin Installation You can install jquery-waves plugin using npm or include directly files install u

İsa Eken 6 Apr 8, 2022
👾 Library to simulate memz-like virus in a browser

Memz.js ?? Library to simulate memz-like virus in a browser jsDelivr <script src="https://cdn.jsdelivr.net/gh/SkwalExe/memz.js@main/src/memz.min.js"><

Skwal 2 Oct 6, 2022
Chrome extension to simulate cryptoblades fights, giving you the win rate % against all enemies with just one click

CryptoBlades fight simulator This is a Chrome extension that will help you to know the exact win rate percentage you have on each cryptoblades fight.

Jose Leonardo Dos Ramos Rivas 12 Aug 7, 2022
In this repository, I try to perform a mainnet fork and then simulate popular smart contract exploits on various DEFI Protocols using Hardhat Framework.

defiHacks_via_Hardhat 1. Alchemix Access Control Bug Any user could have called setWhitelist() to give an attacker the ability to call the harvest fun

null 34 Dec 27, 2022
Progressive Web App (PWA) built in Node.js & Express that automatically reloads/refreshes your browser, web page, and app when developing.

Expresso ☕️ Checks for changes in your source and automatically reloads your browser, or web page, and app window. Makes development easier. Report Bu

Start Rev Technology 3 Oct 6, 2022
This is a full-stack exercise tracker web application built using the MERN (MongoDB, ExpressJS, ReactJS, NodeJS) stack. You can easily track your exercises with this Full-Stack Web Application.

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

WMouton 2 Dec 25, 2021
Mercury: easily convert Python notebook to web app and share with others

Mercury Share your Python notebooks with others Easily convert your Python notebooks into interactive web apps by adding parameters in YAML. Simply ad

MLJAR 2.2k Dec 30, 2022
Allows the public to easily report and track the geolocation of anyone or anything they spot outside, using a mobile app or web frontend.

LIVE DEMO: https://armytracker.com/ (tracking the invading Russian army in Ukraine) Attention: - If you'd like to help the project either as a program

Michal Certicky 9 Mar 27, 2022
Easily publish notes to the web This plugin integrates with obsius.site to publish markdown notes on the web.

Obsius Publish Easily publish notes to the web This plugin integrates with obsius.site to publish markdown notes on the web. Limitations The type of c

Jon Grythe Stødle 66 Dec 20, 2022