      SUBROUTINE SEDRCRU(GMT,NAV,MPE,SPV,ANG,MTB,MHG,MTB5,RANGE)
C
C COMPUTE THE TRANFORMATION FROM THE EARTH MEAN ECLIPTIC AND EQUINOX
C OF 1950.0 (EME'50) COORDINATES TO HELIOGRAPHIC COORDINATES.
C
C INPUT NAVIGATION RECORD DATA (NAV) AND POINTING VECTOR DATA (MPE)
C
      INTEGER*2 GMT(6)
C
      REAL*4 NAV(252),RE(3),RH(3),VE(3),VH(3),SPV(6),ANG(2),      
     &       MHG(3,3),MTB(3,3),M5(3,3),MPE(3,3),MTB5(3,3)
C
      DATA TPIE / 6.2831853E0 /, ARAD / 1.495985E8 /
C
C M5 IS A PSEUDO-CONSTANT ORTHOGONAL MATRIX THAT MAPS VECTORS FROM THE EARTH-
C MEAN-ECLIPTIC, EQUINOX OF 1950 (EME'50) INERTIAL SYSTEM TO AN INERTIAL 
C HELIOGRAPHIC SYSTEM (IHG).
C
C MTB5 IS THE EME'50 TO HG TRANSFORMATION MATRIX (MTB5)
C
C MHG IS THE PAYLOAD TO HG TRANSFORMATION MATRIX (MHG)
C
      DATA M5 / 0.2576, 0.9662, 0.0   ,  
     &         -0.9585, 0.2555, 0.1262,  
     &          0.1219,-0.0325, 0.9920 /
C
      INCLUDE 'UNPACK.INC'
C 
C LOAD S/C POSITION VECTOR INTO ARRAY RE.
C
      RE(1) = NAV(13)
      RE(2) = NAV(14)
      RE(3) = NAV(15)
C
C LOAD S/C VELOCITY VECTOR INTO ARRAY VE.
C
      VE(1) = NAV(16)
      VE(2) = NAV(17)
      VE(3) = NAV(18)
C
      DO I = 1,3
       RH(I) = ( M5(1,I)*RE(1) + M5(2,I)*RE(2) + M5(3,I)*RE(3) ) / ARAD
       VH(I) =   M5(1,I)*VE(1) + M5(2,I)*VE(2) + M5(3,I)*VE(3)
      END DO
C
C GET IHG SPACECRAFT LATITUDE (THETA) AND LONGITUDE (BETA), AND 
C IHG TO HG TRANSFORMATION MATRIX (MTB).
C 
      X = RH(1)
      Y = RH(2)
      Z = RH(3)
      RANGE = SQRT(RH(1)**2+RH(2)**2+RH(3)**2)
C
C SPACECRAFT LATITUDINAL POSITION ANGLE
C
      THETA = ASIN(Z/RANGE)
C
C SPACECRAFT LONGITUDINAL POSITION ANGLE
C
      BETA = ATAN2(Y,X)
      IF (BETA.LT.0.0) BETA = BETA + TPIE
C
      DEN = SQRT(X**2 + Y**2)
      CSB = X/DEN
      SNB = Y/DEN
      SNT = Z/RANGE
      CST = SQRT(1.0 - SNT**2)
C
      MTB(1,1) =  CST*CSB
      MTB(1,2) = -SNB
      MTB(1,3) = -SNT*CSB
C
      MTB(2,1) =  CST*SNB
      MTB(2,2) =  CSB
      MTB(2,3) = -SNT*SNB
C
      MTB(3,1) =  SNT
      MTB(3,2) =  0.0
      MTB(3,3) =  CST
C
      SPV(1) = RH(1)
      SPV(2) = RH(2)
      SPV(3) = RH(3)
      SPV(4) = VH(1)
      SPV(5) = VH(2)
      SPV(6) = VH(3)
      ANG(1) = BETA
      ANG(2) = THETA
C
C GET EME'50 TO HG TRANSFORMATION MATRIX (MTB5)
C
      DO I = 1,3
       DO J = 1,3
        MTB5(I,J) = MTB(1,I)*M5(J,1) + 
     &              MTB(2,I)*M5(J,2) + 
     &              MTB(3,I)*M5(J,3)
       END DO
      END DO
C
C GET PAYLOAD TO HG TRANSFORMATION MATRIX (MHG)
C
      DO I = 1,3
       DO J = 1,3
        MHG(J,I) = MTB5(I,1)*MPE(1,J) + 
     &             MTB5(I,2)*MPE(2,J) + 
     &             MTB5(I,3)*MPE(3,J)
       END DO
      END DO
C
      RETURN
      END
