Stiffness
dt = .01; //Make this smaller if you want better accuracy //Read the values into the parameters stiffness=document.inputs.stiff.value; //First give the variables some initial values x1=20; //initial positions of trolleys vx1=0; //initial velocities running=true; StepModel(); //Start the simulation running
//Mass 1 is accelerated by force in spring 1 vx1 += dt * (stiffness * (-x1)); //Update the positions x1 += dt * vx1; MoveTrolleys(x1,x2); if(running){setTimeout('StepModel()',10);}