Live data from Hacker News

Simulation class: 2D wave equations (in browser)

encinographic.blogspot.com

11–14 of 14 posts

Re: Simulation class: 2D wave equations (in browser)

#11
I loved playing around with this kind of water simulation when I was younger, the basic principle behind it is very simple. Spent many hours optimizing C++ and OpenGL code.

I still haven't figured out though how to stop wave reflection at the edges though...

Re: Simulation class: 2D wave equations (in browser)

#12
post #11

I loved playing around with this kind of water simulation when I was younger, the basic principle behind it is very simple. Spent many hours optimizing C++ and OpenGL code. I still haven't figured out though how to stop wave reflection at the edges though...

The trick is to perform damping around the edges in a hidden border around the heightmap. Say you wanted to simulate a 500x500 heightmap. You would actually calculate the results for a 700x700 heightmap, (which contains a hidden border of width 100 around each edge). The hidden edges are slowly damped away by multiplying by a factor interpolated between 1 (on the inner edge of the visible part of the heightmap) 0 (on the very outside of the heightmap).

This works remarkably well; you can see this approach in action in http://www.falstad.com/ripple/ for instance. Source code is included on the page.

Re: Simulation class: 2D wave equations (in browser)

#13
post #11

I loved playing around with this kind of water simulation when I was younger, the basic principle behind it is very simple. Spent many hours optimizing C++ and OpenGL code. I still haven't figured out though how to stop wave reflection at the edges though...

The trick is to perform damping around the edges in a hidden border around the heightmap. Say you wanted to simulate a 500x500 heightmap. You would actually calculate the results for a 700x700 heightmap, (which contains a hidden border of width 100 around each edge). The hidden edges are slowly damped away by multiplying by a factor interpolated between 1 (on the inner edge of the visible part of the heightmap) 0 (on…

Thanks for the answer, I actually tried something like that but it never worked out completely. There always was a small residual amount of noise that prevented simulating a true infinite pool. I tried to come up with the necessary equations for the pool margins so that I wouldn't need a hack, but couldn't figure it out. One of those days I will!

Re: Simulation class: 2D wave equations (in browser)

#14
post #10

I wondered what language it was written in and found out after a little research: http://processing.org/

Yes, all his code is available at the github repo linked at the end of the page [1], and .pde is a Processing file.

[1] https://github.com/blackencino/SimClass

Post reply on HN