R
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.8; //initial velocity StepModel(); //Start the simulation running
r=Math.sqrt(x*x+y*y); //radius accx= -x/(r*r*r); //acceleration in x direction accy= -y/(r*r*r); // " " in y direction vx+=accx*dt; vy+=accy*dt; x+=vx*dt; y+=vy*dt; Moveball(1, x, y, 0); //Move the blue satellite document.inputs.radius.value = r; //Show the values document.inputs.posx.value = x; document.inputs.posy.value = y; if(running){setTimeout('StepModel()',10);}