wow

04-19-2004, 05:04 AM

Hi all, below is the pseudocode for the water ripple calucation:

damping = some non-integer between 0 and 1

begin loop

for every non-edge element:

loop

Buffer2(x, y) = (Buffer1(x-1,y)

Buffer1(x+1,y)

Buffer1(x,y+1)

Buffer1(x,y-1)) / 2 - Buffer2(x,y)

Buffer2(x,y) = Buffer2(x,y) * damping

end loop

Display Buffer2

Swap the buffers

end loop

I want to ask why buffer2(x,y) need to be calculated in this way:

Buffer2(x, y) = (Buffer1(x-1,y)

Buffer1(x+1,y)

Buffer1(x,y+1)

Buffer1(x,y-1)) / 2 - Buffer2(x,y)

??

thx a lot

damping = some non-integer between 0 and 1

begin loop

for every non-edge element:

loop

Buffer2(x, y) = (Buffer1(x-1,y)

Buffer1(x+1,y)

Buffer1(x,y+1)

Buffer1(x,y-1)) / 2 - Buffer2(x,y)

Buffer2(x,y) = Buffer2(x,y) * damping

end loop

Display Buffer2

Swap the buffers

end loop

I want to ask why buffer2(x,y) need to be calculated in this way:

Buffer2(x, y) = (Buffer1(x-1,y)

Buffer1(x+1,y)

Buffer1(x,y+1)

Buffer1(x,y-1)) / 2 - Buffer2(x,y)

??

thx a lot