Particle Simulator

Sun, 07 Oct 2007

Sometimes it is useful to have a physics simulator, for doing whatever you do with a physics simulator. I was doing a little bit of work on one recently, so if you want to have a play, then this has it. There isn't very much insighful about it, it is just a simple engine:

Screenshot

  • Verlet integration (makes collision resolution lots simpler)
  • Handles spheres of different weights
  • Crashes on singularities
  • Handles a few different global constraints (all objects inside a sphere, all objects have some coordinate < k
  • Handles a few different object constraints (two objects stay a fixed distance apart, an object stays at a fixed point)
  • Not numerically stable (this is a todo)
  • Brute force algorithms in too many spots (this is a todo)
  • Becomes unusable when processing gets too hard
  • Slow and ugly view of the world

Although it supports spheres, I didn't feel like doing 3d graphics, so I just set the z coordinate of everything to 0, and because of the accuracy of a computer, all the spheres magically balance on each other.

The direction this is going is to get something where I can approximate a fluid in a reasonably complex system. To do that, it needs to be able to support more spheres (so it will need a better way of indexing objects to cut down on collision detection time), able to support triangles (so you can model lots more things), and be a bit more stable (so it is more fun to play with). This will probably also involve switching the graphical frontend to something different so it is quicker to redraw (and thus more fun to play with).

Get it here (GPL3) I've included an executable file, which I suspect will work on pretty much any Linux system with GTK+ (which should be lots), and also the source (which should be compilable on Windows with GTK+ libs). It isn't my prettiest code, but it should be reasonably ok to hack around. There are a couple of spots where I know I'm going to have to re-engineer large sections of code.

It is actually quite fun to play with. You control the large ball with your mouse, so you can bump the other balls, and try to keep them up in the air or whatever. I can easily imagine a fun game being made from it - I just need triangles so I can build a net and it is an awesome tennis game :)

Name & email are optional. Email will not be obfuscated.
HTML tags will be removed except hyperlinks.
 

About

I'm a nerd living in Sydney. This is a place where I can write stuff about my interests and not care that no one else is reading.

I like music, maths, programming, pretty pictures, filters and other good things.

(more info)

It should be fairly obvious that this isn't connected to my employer at all.

Email me (not a catchpa)

Email policy

Subscribe

RSS Feed RSS

Get an aggregator

Liferea (Linux)

Vienna (OSX)

Feedreader (Windows)

Google Reader (Web based)

I've only used Liferea, so I can't vouch for the other ones.

About this site

This site runs a (modified) version of blosxom.

The host is GeekISP, and they seem to do an excellent job.