Unconstrained Physics

mass (kg):
x0 (m):
y0 (m):
theta0 (rad):
vx0 (m/s):
vy0 (m/s):
vAng0 (rad/s):
forceX (Newton):
forceY (Newton):
forcePoint:
tStop (s):

t=0s

Notes on the source code

Most of the relevant code is in unconstrained_physics.js, except for a small math library for vector operations, which is in MV.js, and the code for plotting, which is in the page source itself. For plotting, I use flot.

The code is rather readable I hope, and serves as a basis for the next two pages about constraints. The only ugly portion is the plotting part, but the physics code is pretty compact: there's a class Body and a class World. Bodies are instantiated and added to an instantiated world, then one steps through time by calling world.step() in each time step, followed by redrawing the bodies.

Please get in touch with me (hubert@THISDOMAIN) if anything is wrong, doesn't work or is unclear