FFT Water - Maths confusion!
Hi all,
I'm currently trying to implement the first part (FFT) of this article for a water surface (a 16x16 grid of points):
http://www.gamasutra.com/gdce/2001/jensen/jensen_01.htm
I just can't seem to get my head around the math, and it doesn't help that it's really hard to see some of the small text in certain formulas.
Has anyone managed to get a working version of this up and running? If so, i'd really appreciate some help. If anyone is able to translate what exactly you are supposed to do with the formulas into some nice pseudocode that would be awesome!
I just can't figure out how to use it to give me the correct height values I can plug in to my grid.
I guess i'll expand a bit on the problem then:
Firstly, in the first formula, can anyone make out what the end part says?
I think it might be e^(iK - X)....? If so, what does the small 'i' in front of the 'K' signify? Can't seem to find that out.
The small 'i' also appears in the fourth formula with no explanation, and then again in the 7th formula.. what does it mean?
That's just the start of the problem, but getting that part worked figured out should help me get further.
Firstly, in the first formula, can anyone make out what the end part says?
I think it might be e^(iK - X)....? If so, what does the small 'i' in front of the 'K' signify? Can't seem to find that out.
The small 'i' also appears in the fourth formula with no explanation, and then again in the 7th formula.. what does it mean?
That's just the start of the problem, but getting that part worked figured out should help me get further.
Yep, it's an i. i is the iteration number, so if the sum goes from 0 to K, each iteration will have i equal to 0,1,2,3,...,K
Hi,
sorry to correct you but i is not the iteration variable. The i is a the complex i, since the k is under the sum, k is the iteration variable.
So look up Fourie Transformations (FT).
Sorry for my bad english but it'n not my motherlanguage.
sorry to correct you but i is not the iteration variable. The i is a the complex i, since the k is under the sum, k is the iteration variable.
So look up Fourie Transformations (FT).
Sorry for my bad english but it'n not my motherlanguage.
Oops, you're absolutely right dragongame. That'll teach me for only glancing at it quickly.
yes
e^(i*theta) = cos(theta) + i * sin(theta)
i^2 = i*i = -1 (yes !!)
its all about complex numbers. You should see that in high school i think. (In france, we see it when we are about 16/17 year old)
neyna
e^(i*theta) = cos(theta) + i * sin(theta)
i^2 = i*i = -1 (yes !!)
its all about complex numbers. You should see that in high school i think. (In france, we see it when we are about 16/17 year old)
neyna
Getting somewhere now, thanks for the additional input guys. Still not sure i'm ever gonna get my head around this. Has anyone out there managed to implement this and would like to offer advice?
well, as i don't have enough time, i just quickly go thru some important points.
Firstly, calculate Ph(K), using the fifth formula. this is pretty straight forward.(the Philips spectrum)
Secondly, calculate h0, which is the amplitudes and phases at time zero, by using the result from above step and the 7th formula.( or u can simply use ordinary noise for it) And remeber h0 is a complex number.
the 1st and 2nd steps are done in preprocessing stage.
Thirdly, in the runtime, u calculate the ~h(K, t).(formula 8). Here the e term is not e^(iK - X), it should be e^(i * dot(K,X))
dot stands for dot product.
Then the ~h(K,t) will be applied to the 1st formula. There are sth need to be mentioned that for the 1st formula, u can actually simplify the e term to just 1.
K = (2*PI*n/s, 2*PI*m/s), X = (n*s/r, m*s/r)
so dot(K, X) = (2*PI*n^2/r) + (2*PI*m^2/r) ------(1)
substitute (1) into the e term in the 1st formula, and using some formulas, the e term will be turned into 1.( The key is PI and 2*n^2/r, as e^(i*PI) = -1, so the whole e term can be
-1^(2*(n^2 + m^2)/r) = -1^((2n^2 + 2m^2)/ -1^r) = 1, since r is power of 2, and 2n^2 + 2m^2 is always even.
so, finally the 1st formula becomes h(X, t) = SUM_K ~h(K,t)
Lastly, u use FFTW or whatever to get h(X, t)[still complex number], and the real part of it is the height value u long for. :D
[Edited by - wanzi on September 22, 2004 5:36:24 PM]
Firstly, calculate Ph(K), using the fifth formula. this is pretty straight forward.(the Philips spectrum)
Secondly, calculate h0, which is the amplitudes and phases at time zero, by using the result from above step and the 7th formula.( or u can simply use ordinary noise for it) And remeber h0 is a complex number.
the 1st and 2nd steps are done in preprocessing stage.
Thirdly, in the runtime, u calculate the ~h(K, t).(formula 8). Here the e term is not e^(iK - X), it should be e^(i * dot(K,X))
dot stands for dot product.
Then the ~h(K,t) will be applied to the 1st formula. There are sth need to be mentioned that for the 1st formula, u can actually simplify the e term to just 1.
K = (2*PI*n/s, 2*PI*m/s), X = (n*s/r, m*s/r)
so dot(K, X) = (2*PI*n^2/r) + (2*PI*m^2/r) ------(1)
substitute (1) into the e term in the 1st formula, and using some formulas, the e term will be turned into 1.( The key is PI and 2*n^2/r, as e^(i*PI) = -1, so the whole e term can be
-1^(2*(n^2 + m^2)/r) = -1^((2n^2 + 2m^2)/ -1^r) = 1, since r is power of 2, and 2n^2 + 2m^2 is always even.
so, finally the 1st formula becomes h(X, t) = SUM_K ~h(K,t)
Lastly, u use FFTW or whatever to get h(X, t)[still complex number], and the real part of it is the height value u long for. :D
[Edited by - wanzi on September 22, 2004 5:36:24 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement