This project simulates the motion of ocean waves using a simple mathematical model based on the Gerstner wave model. Implemented in Python, the simulation generates visually realistic ocean wave patterns over time using the Matplotlib library. The animated simulation is saved as a GIF.
Ocean waves are complex natural phenomena influenced by various factors such as wind and gravity. This project simulates ocean waves using a parametric surface model to represent wave behavior over time. The primary objective is to create a computationally efficient and realistic visualization of ocean waves.
We employed the Lagrangian method to model the surface of the ocean. In this approach, the motion of individual points on the ocean surface is calculated based on sinusoidal wave equations. The surface is treated as a graphical primitive, and particles are set in circular motion around their rest positions, creating the wave-like movement.
For the X and Z coordinates of each point:
-
X-coordinate:
x = x_0 + r * sin(k * x_0 - ω * t)
-
Z-coordinate:
z = z_0 - r * cos(k * x_0 - ω * t)
Where:
r
is the wave amplitudek
is the wavenumberω
is the angular frequencyt
is time
These equations generate the trochoidal shape of waves over time, creating a visually appealing simulation of ocean surface dynamics.
- Language: Python
- Libraries: Numpy, Matplotlib, Matplotlib Animation
The ocean surface is represented by a grid, and the height of the waves is computed at each point using wave equations. The animation is created using the matplotlib.animation
module, which updates the wave positions over time.
The animated wave simulation is stored as a GIF file.
Here is a GIF of the generated ocean wave simulation:
The generated waves realistically depict the motion of the ocean surface, with varying wave heights and movements that closely resemble natural ocean behavior.
- Wave Interaction: Introduce wave interference and interaction to simulate more complex wave patterns.
- Foam and Surf: Add a particle system to simulate foam and surf near the shorelines.
- Wind Influence: Model wind direction and speed to dynamically alter wave patterns.