Sign in to follow this  
Nemrav

Ocean Wave problem

Recommended Posts

So as a proper, over ambitious programmer, I decided to tackle a problem that is at least 3-6 years worth of education above my head, delving into big scary math where nobody my age (nor my teachers for that matter) have dared bury their heads in equations before.

For context, this is where my problem comes from : http://www-evasion.imag.fr/Membres/Fabrice.Neyret/NaturalScenes/fluids/water/waves/fluids-nuages/waves/Jonathan/articlesCG/simulating-ocean-water-01.pdf

I want to try to simulate ocean waves before I get into other scary water related math problems. I currently have two problems, they both involve programming the equation: 

The equation
h(x, t) = Ʃ  mean_h(k, t) exp (ik · x) 
             k


where h is the height, x is the wave direction vector (2d vector), mean_h is h with a line over it (I believe it is the mean height, hence the name) , t is time, k is another 2d vector that I think I've defined in programming.                                (this is more clearly on the article at 4.3, equation 36 in the article)

But some parts of the equation raise questions... such as what to do with the  exp(ik * x) , I can do the exp(I * x) just fine (its obviously a dot product), but how do I treat the i, it appears to indicate the complex number, but what should I do ? supposing that just means (0,1) (since it can mean that), what do I do between it and the I (ik * x), should I do a cross product or a dot product seeing as it doesn't have a dot unlike the other term.

The second problem I have is putting the sigma into programming, the person who wrote the equation does not give everything that summation normally does, it uses a vector of all things as the start point, gives no end... It also leaves me clueless as to the mean height, how do I obtain it ? it doesn't indicate in the article, is it just a product of the summation ?

tl;dr  : I have math problems with that equation involving just about everything  after the = sign.

Share this post


Link to post
Share on other sites

I won't pretend to know the answer to your question, but let's see if I can use the powers of the forum to summon someone who I believe does.

@Yourself, your self is needed!

Share this post


Link to post
Share on other sites

Complex numbers are common in frequency related physics. Complex exponential function can be calculated exp(a + b*i) = exp(a) * (cos(b) + i*sin(b)).

Wikipedia is useful reference:

https://en.wikipedia.org/wiki/Euler's_formula

You calculate with complex numbers and when you are ready to draw you take (typically) real part of result as a height value.

I noticed that you asked also about vectors. It is scalar product between wave vector k and position vector x. You get some angle like number and use Euler's formula to get a complex number. You calculate sum and then use real part to get height on point x.

There is some set of wave vectors. You sum over all of them. I can read the paper and give more advice after about 1 hour.

Edited by Hannu2
More information

Share this post


Link to post
Share on other sites

OK, I am back. It seems to be equation 36. It is standard 2D inverse discrete Fourier transform. h_tilde(k) is amplitude and phase of the wave with wave vector k. Wave vectors describe plane waves (straight sine waves). Length of k is 2*pi/wavelength and its direction is direction of wave propagation. In this case you take a square area with side length L and divide it to N * N grid points. You can take values from article. You get N^2 k vectors k_m,n = (2*pi*m/L, 2*pi*n/L), where m and n goes from 0 to N-1. This is set over which summations go.

Next you need h_tilde(k). You can use formulas 39-43. They should be quite straightforward to apply. Here you can find how to convert uniformly distributed random numbers to Gaussian distribution. Now your have everything to calculate inverse Fourier transform. Straightforward algorithm would have time complexity of N^4. It is something you do not want to even try if you want to high quality surfaces. Use Fast Fourier Transform algorithm (FFT) (as article suggest) which takes time only N^2*log(N) (difference is about 100000 at N = 1024). FFTs are well investigated area in mathematics and computational science due to its huge importance in signal processing but I am not expert in FFTs. This is one example code and Google can find many more. There are also code libraries (also free) with efficient FFT algorithms.

There may be errors in my formulas. It is better to check them with that article. I suggest that you program this basic level before moving to forward in article. Please ask if you need or I overestimated your level.

Share this post


Link to post
Share on other sites

Thankyou, you explained it in a way that I wish all papers did ! I will be advancing with this problem, and if I get everything, I will be sure to post my results !

Thankyou !

(I was kind-of aware of FFT's, though I still don't understand them well, but I was completely unawares of Euler's formula)

Share this post


Link to post
Share on other sites
This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this