Tension
X
Y
running=true; //First give the variables some initial values dt = .01; //Make this smaller for better accuracy x=0.9; //initial position y=0; vx=0; vy=0; //initial velocity StepModel(); //Start the simulation running
length = Math.sqrt(x*x+y*y); if(length>1){ tension = g*(length - 1); }else{ tension = 0; } vx -= dt * tension * x/length; vy -= dt * (tension * y/length + g); x += dt * vx; y += dt * vy; Moveball(x,y,0); document.inputs.radius.value = tension; //Show the values document.inputs.posx.value = x; document.inputs.posy.value = y; if(running){setTimeout('StepModel()',10);}