5
\$\begingroup\$

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?

\$\endgroup\$
4
  • \$\begingroup\$ This is interesting, but what does this have to do with Java? \$\endgroup\$
    – Lysol
    Feb 3, 2014 at 19:49
  • \$\begingroup\$ I have been attempting to implement it into java. And thus i needed to simplify it. \$\endgroup\$
    – user41715
    Feb 4, 2014 at 4:50
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – Lysol
    Feb 4, 2014 at 5:32
  • \$\begingroup\$ 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. \$\endgroup\$
    – user41715
    Feb 4, 2014 at 5:34

2 Answers 2

2
\$\begingroup\$

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}
    ]
]
\$\endgroup\$
3
  • \$\begingroup\$ +1 for the graphic exemples ! don't know what you used to generate those, but its awesome. \$\endgroup\$ Feb 4, 2014 at 14:35
  • \$\begingroup\$ i would love to know what you used too :) \$\endgroup\$
    – NeeL
    Feb 6, 2014 at 20:44
  • 1
    \$\begingroup\$ @NeeL: Wolfram Mathematica. I've appended the code used to generate these animations. \$\endgroup\$ Feb 6, 2014 at 21:18
5
\$\begingroup\$

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(α)
\$\endgroup\$

You must log in to answer this question.