running=true; //First give the variables some initial values l1=1; l2=1; x1=.1; x2=.3; y1=-l1; y2=-l1-l2; vx1=0; vx2=0; dt = .01; //Make this smaller for better accuracy Moveball(ball0,0,0,0); StepModel(); //Start the simulation running
acc1=-2*x1/l1 +(x2-x1)/l2; acc2=(x1-x2)/l2; vx1+=acc1*dt*g; vx2+=acc2*dt*g; x1+=vx1*dt; x2+=vx2*dt; Moveball(ball1,x1,y1,0); Moveball(ball2,x2,y2,0); if(running){setTimeout('StepModel()',10);}