This is a simple implementation of the 2D wave equation in WebGL.
The goal of this project is to implement a solution to the wave equation based on Fourier's Method. Explaining method is beyond the scope of this post and will not be covered for now.
Click to check out the online demos running in WebGL:
The goal of this project is to implement a solution to the wave equation based on Fourier's Method. Explaining method is beyond the scope of this post and will not be covered for now.
Click to check out the online demos running in WebGL:
The Math
The problem presented is the following:
$$\begin{cases} u_{tt} = c^2(u_{xx} + u_{yy}) & 0 < x < a, 0 < y < b \\ u(0, y, t) = u(a, y, t) = 0 & 0 < t < ∞ \\ u(x, 0, t) = u(x, b, t) = 0 & 0 < t < ∞ \\ u(x, y, 0) = f(x, y) & 0 < x < a, 0 < y < b \\ u_t(x, y, 0) = 0 & 0 < x < a, 0 < y < b \end{cases}$$
For simplicity I'm taking ut(x, y, 0) = 0 and a = b = 1
The solution can be written as :
The solution can be written as :
$$u(x, y, t) = \sum_{m=1}^∞\sum_{n=1}^∞a_{mn} cos(k_{mn}ct)sin(\frac{m\pi x}{a})sin(\frac{n\pi y}{b})$$
$$a_{mn} = \frac{4}{ab} \int_0^a\int_0^bf(x,y) sin(\frac{m\pi x}{a})sin(\frac{n\pi y}{b}) dy dx$$
Simulation
Now, to produce the wave simulation I'm computing the Fourier series with a finite number of terms M and N like so: