View Full Version : Particle Physics Equations

06-14-2007, 03:29 AM
Inspired by Gravitas (http://www.galaxydynamics.org/), I decided to make a similar simulation in JS, visualized with the canvas element. It's pretty nice, albeit slow (I can run about 10 particles max before it gets choppy), but the particles simply don't behave as those in the Gravitas videos do. That they don't merge together is my main concern.

I've tried to code the equations as accurately as possible to real physics equations. The code is attached, run ParticleSystemTEST.html to see it in action. The equations/gravitational constants are mostly in ParticleSystem.prototype(.updateGravity), Particle.get(Displacement|VelocityChange)After, and Vector.getAccelerationOf.

If someone with physics knowledge would look at this (I think/hope its sufficiently commented) and suggest changes, I would appreciate it. Also, speed optimization would be nice, too.