The gerstner wave function is a commonly used method to calculate waves and simulate water in video games and movies or most 3d simulations. It is however quite complex so it is very hard for young developers such as myself to understand and implement it into code.
Would it be possible to simplify the formula:
- A = amplitude of wave (Float)
- W = wave number (Vector)
- D = direction (Vector) how do i know what to set the direction to?
- S = Speed
- L = wave length
- phase-constant = S x 2* pi/L.
According to the article Q = 1/(W * A)
Issues and Questions:
- Why are all three lines of the formula seperated by commas?
- D refers to a directional vector (i think)
- Q = 1/(W * A) but W is a vector and A is a float?
- What does this line mean: wiDi.(x,y) is that reffering to w * dot product of(d , (x,y))
- sigma returns the sum of what exactly?
Here is my attempt to implement it into java code:
float yPos = (float) ((steepness * amplitude) * direction.y * Math.cos(wavenumber.y * (direction.dot(position)) + phase_const * time));
Dont know if its correct
This may help: