wx
wy
wz
running=true; //First give the variables some initial values // setballs ballx[0]=Array(.5,.5,0); ballx[1]=Array(.5,-.5,0); ballx[2]=Array(-.5,.5,0); ballx[3]=Array(-.5,-.5,0); jx=0; //Calculate the principal moments jy=0; jz=0; for(i=0;i
//Transform cworld to cgyro in gyro axes cgyro=Array(0,0,0); for (ii=0;ii<3;ii++){ for(jj=0;jj<3;jj++){ cgyro[ii]+=transform[jj][ii]*cworld[jj]; } } dwx=((jy-jz)*wy*wz + cgyro[0])/jx; dwy=((jz-jx)*wz*wx + cgyro[1])/jy; dwz=((jx-jy)*wx*wy + cgyro[2])/jz; wx+=dwx*dt; wy+=dwy*dt; wz+=dwz*dt; omega(wx,wy,wz); //rotate and show the balls document.inputs.posx.value = wx; document.inputs.posy.value = wy; document.inputs.posz.value = wz; if(running==true){setTimeout('StepModel()',10);}