Live data from Hacker News

Web GL Ocean Simulation

david.li

81–90 of 138 posts

Re: Web GL Ocean Simulation

#82
post #76
post #48

Earlier quoted context omitted.

I'm not implying yours are not unstable, it's just there is a chance it might be. Typically exact formulas exhibit such properties. LU decomposition is numerically stable, for the most part. You can run into problems with floating point arithmetic if you're not careful. This just has to do with the way you solve the problem. By breaking up the matrix into an upper and lower triangular part and solving the resulting t…

Wait, no, LU decomposition is not stable unless you're doing pivoting. And if you're doing pivoting, then it very much stops looking like an "exact formula", because it'll get filled up by ifs and variable renamings, etc. There's plenty of cases in graphics and simulation where solving even a 4x4 matrix needs careful numeric consideration (see this paper about tetrahedral mesh simplification, section III.D, page 7: h…

You are quite correct about stability but I didn't want to get into technical details. And indeed you bring up correctly that such numerical issues mustn’t be treated lightly. I don't do computer graphics and the matrices I deal with are well conditioned such that problems of stability that arise due to linear algebra routines are negligible. In my simulations, instability arises due to the wrong time-stepping scheme, which is a completely different issue.

And good recommendation by Strang. I believe he has some fantastic MIT OpenCourse lectures on numerical linear algebra as well.

Re: Web GL Ocean Simulation

#84
post #55

Earlier quoted context omitted.

Look into something like Octave, where matrices are first-order data types, and you'll know exactly what he means.

Had a look. Still think JS is fine.

JS is fine; in the same way that is fine to use a sandbox shovel to dig the foundation of a house. Languages are designed for a purpose, though they can be used for all sorts of things.

There is a larger upfront cost to learning the right language for the right job. However, many people opt to try to fit a square peg into a round hole.

Re: Web GL Ocean Simulation

#85
post #20

Where would one start if they wanted to learn the math needed to achieve something like this?

I've alluded to this in other comments but a lot of the mathematics is linear algebra. As gaius mentions, check out the wikipedia article. There are plenty of linear algebra books out there. Recently I've really enjoyed the book by Meyer which is free although it does get quite advanced and is mostly theorem / proof-style. It's also free so who can complain.

http://matrixanalysis.com/DownloadChapters.html

Here is a link I found yesterday which gets you solving the 2D NS equations.

http://lorenabarba.com/blog/cfd-python-12-steps-to-navier-st...

I've take a quick look through it and it seems pretty good. It introduces many of the most important ideas of solving PDEs. Obviously there are huge tomes on various techniques to solve the Navier-Stokes equations but this link, I think, does a pretty good elementary introduction. A more comprehensive treatment would require a more thorough background in mathematics (e.g. I wrote a 2D NS solver using the vorticity formulation and FFTs but to understand the equivalence requires a greater background).

As for the cool visualisation, I cannot help you. I don't know any fancy graphics programming since I normally use the built-in plotting tools of Python and Matlab.

Re: Web GL Ocean Simulation

#86
post #5

The code is quite cool to look at. Love seeing the extensive use of matrices and mathematics to create such a beautiful and mesmerizing display. If anyone is interested in playing around with it, I threw it up at JSFiddle here: http://jsfiddle.net/zyAzg/ Excellent demo.

Great demo, well written code. Though reading through it also highlights that JS is not a great language for linear algebra. But I don't think anyone is really suggesting otherwise.

Can I ask why JS is no good? (Genuine question)

I thought the only consideration would be speed? The algebra is mainly looping. Isn't that way most languages try to handball algebra to LAPACK/BLAS?

Re: Web GL Ocean Simulation

#87
post #71
post #66

Earlier quoted context omitted.

Unless you like econometrics: then X are data, betas and gammas and sigmas are unknown (oh my!). Jargon is fun, unless I want to communicate across fields :/.

Well today I learned. I never knew that. Stupid mathematics and its inconsistent notation.

It makes sense when you look at historical development, but there is no reason to learn separate notations now without learning all sides :).

Re: Web GL Ocean Simulation

#88

Earlier quoted context omitted.

"JS is not a great language for linear algebra." what does that even mean? It's a general purpose language. It all boils down to how you want to use it, like any other general purpose language. A lot of times in cases like this, people choose not to make it look pretty and easy to read to gain performance. This simulation is very CPU intensive, trying to have pretty code and speed is going to be tough.

Look into something like Octave, where matrices are first-order data types, and you'll know exactly what he means.

Or look at Python/Numpy. General purpose language with a sufficiently advanced library that doing linear alg stuff becomes a very pleasant experience. Way, way, way nicer than spelling it all out like this JS code has to.

Then again, I might be biased there since I've spent a decent chunk of time porting MATLAB/Octave code to Python/Numpy so that we could get it into production in a robust way..

Re: Web GL Ocean Simulation

#90

This runs at about 7 frames per second in Chrome on my 10-month-old 13" Macbook Pro at work. Are people with better graphics cards seeing 60 (or even 30) fps? I'd love to be able to see this in all its glory.

60fps here (3.4ghz Core 2 Quad/GTX 470/Firefox/fullscreen 1920x1200). CPU usage is 9%, GPU usage is 22%.
Post reply on HN