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