R
X
Y
Z
running=true; //First give the variables some initial values dt = .01; //Make this smaller for better accuracy x=0.8; //initial position y=0; z=.5; vx=0; vy=0.4; vz=0.7; //initial velocity StepModel(); //Start the simulation running
r=Math.sqrt(x*x+y*y+z*z); //radius accx= -x/(r*r*r); //acceleration in x direction accy= -y/(r*r*r); // " in y direction accz= -z/(r*r*r); // " in y direction vx+=accx*dt; vy+=accy*dt; vz+=accz*dt; x+=vx*dt; y+=vy*dt; z+=vz*dt; Moveball(1, x, y, z); //Move the blue satellite document.inputs.radius.value = r; //Show the values document.inputs.posx.value = x; document.inputs.posy.value = y; document.inputs.posz.value = z; if(running){setTimeout('StepModel()',10);}