Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I have been trying to implement the wave equation described in this paper ("Water Simulating in Computer Graphics," Kai Li and Liming Wu) in Java. Part of the paper discusses modeling waves as a sum of sine waves ("sine wave piling"); in that section there an equation for describing a single sine wave:

Y(x,y,t)= A * cos(w *(x,y)+ wt * t + FI; 

where

  • A = amplitude of wave
  • L = wave length
  • w = spatial angular frequency
  • s = speed
  • wt = temporal angular frequency
  • d = direction
  • FI = initiatory phase

I understand that it returns a vector, but I don't see what this section of the formula means:

w *(x,y)

I believe that w is a vector, but I'm not sure if it's a 3D vector or 2D vector, and how it is used. If you have time, could you please explain this formula to me?

share|improve this question
    
This is interesting, but what does this have to do with Java? –  Aidan Mueller Feb 3 at 19:49
    
I have been attempting to implement it into java. And thus i needed to simplify it. –  TastyLemons Feb 4 at 4:50
1  
I know you are implementing it in Java, but I don't think that a Java implementation wouldn't differ from a C++ implementation. This is more of a math/physics question than a programming question is what I am trying to say. –  Aidan Mueller Feb 4 at 5:32
    
Oh yes you are right. Im sorry. I thought if someone knew java really well they might be able to help more or something. BUt yes you are right. –  TastyLemons Feb 4 at 5:34
add comment

2 Answers

up vote 3 down vote accepted

The function returns a scalar, but the variable w is indeed a vector. More traditionally, the one-dimensional wave function is written as:

Ψ(x,t) = A cos( k x - ω t )

In more than one dimension, for example waves in water instead of on a rope, the spatial part is written as the dot product of two vectors:

Ψ(x,t) = A cos( k·x - ω t )

In the formula you referred to, x is written in full as the two-dimensional vector (x,y), the vector k is called w and the symbol * is used to denote a dot product. The wavenumber (or angular spatial frequency) k indicates the direction in which the wave propagates and its magnitude is inversely proportional to the wavelength. The effect of different wavenumbers on the propagation of the wave is illustrated below.

k = (1,0) k = (3,0) k = (1,1)

Per request, below the Mathematica code used to generate these images:

a = 1;
k = {1,1};
\[Omega] = 2\[Pi];
Export["C:\\Users\\Mark\\tmp.gif",
    Table[
        Plot3D[
            a Cos[k.{x,y} - \[Omega] t],
            {x,-2,2},{y,-2,2},
            PlotRange->{-a,a},
            PlotLabel->"k = " <> ToString[k],
            AxesLabel->{"x","y",None},
            Ticks->{Automatic,Automatic,None}
        ],
        {t,0,.96,.04}
    ]
]
share|improve this answer
    
+1 for the graphic exemples ! don't know what you used to generate those, but its awesome. –  PATRY Feb 4 at 14:35
    
i would love to know what you used too :) –  NeeL Feb 6 at 20:44
1  
@NeeL: Wolfram Mathematica. I've appended the code used to generate these animations. –  Marcks Thomas Feb 6 at 21:18
add comment

The formula returns a scalar (the height of the water surface at coordinates x,y), not a vector.

It is hard to tell what the authors had in mind, because the paper is very confused, but my guess is that it should have looked like this:

Y(x,y,t) = A * cos(w * f(x,y) + wt * t + FI)

Where f is a function that controls the shape of the wave.

This function will generate a circular wave centred at x0,y0:

f(x,y) = sqrt((x - x0)² + (y - y0)²)

This function will generate a directional wave with angle α:

f(x,y) = x * cos(α) + y * sin(α)
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.