Hacker News new | past | comments | ask | show | jobs | submit login
Simulation class: 2D wave equations (in browser) (encinographic.blogspot.com)
52 points by jedp on May 30, 2014 | hide | past | favorite | 12 comments



Love it. Perhaps you'll like this nonlinear wave equation (in browser) http://puzlet.com/m/b00f0 .


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


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.


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!


This is just pure awesome. It is so awesome, that I was jealous of the author for not being able to do this first, I almost didn't upvote it out of that jealously--it's that good. Keep up the good work!

(I'm working on hacking together sims myself but for a larger project--I'm part of a computation group at some state uni modeling HED plasmas.)


If you like wave equations, you might also enjoy EmeWave:

http://psych.colorado.edu/~oreilly/emewave.html

The movies at the bottom of the page are great, and if you want to see how it's done, his papers give a thorough and rigorous explanation that is easy to translate into code.


Very nice! I assume clicking inside the panel is like throwing a pebble in a pond? Is this correct?


Yes it is very similar, it sets the value at that grid point to its maximum height. This causes the neighboring grid cells to react accordingly (Laplacian in space), giving the rippling effect.


Nice. Reminds me of old school demo effects.


Amazing!




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: