SUBROUTINE Earth2Acft(HDx,PCx,RLx,Nx,Ex,Vx,Vout) c Subroutine to calculate aircraft-referenced vertical vector c (velocity or accel) from each 40 Hz sample and store in output array c 3D aircraft attitude and 3D earth-referenced vector are inputs c Access to common is not required IMPLICIT none c Passed Parameters REAL HDx(40),PCx(40),RLx(40),Nx(40),Ex(40),Vx(40) ! inputs REAL Vout(40) C Local storage INTEGER i REAL Hd,Pc,Rl DO i = 1,40 ! do all samples this sec Hd = HDx(i) ! easier to work with below Pc = PCx(i) ! all are already in radians Rl = RLx(i) C Only do the calc if attitude info is grossly reasonable IF (Hd.GE.-3.1416 .AND. Hd.LE.6.2832 .AND. ! -180/+360 deg & Pc.GE.-.785 .AND. Pc.LE.0.785 .AND. ! -/+ 45 deg & Rl.GE.-1.57 .AND. Rl.LE.1.57) THEN ! -/+90 deg Vout(i) = & Sin(Rl)*Cos(Hd)*Ex(i) - & Cos(Rl)*Sin(Pc)*Sin(hd)*Ex(i) - & Sin(Rl)*Sin(Hd)*Nx(i) - & Cos(Rl)*Sin(Pc)*Cos(Hd)*Nx(i) + & Cos(Rl)*Cos(Pc)*Vx(i) ELSE ! bad angle Vout(i) = -999. ! flag it for next calc ENDIF END DO ! end of loop on 40 samples RETURN END