      SUBROUTINE HG(MHG,MTB,MSUN)
C
C COMPUTE PAYLOAD TO HG ROTATION MATRIX (MHG).
C
      REAL*4 MHG(3,3),MTB(3,3),MSUN(3,3)
C
      MHG(1,1) = MTB(1,1)*MSUN(1,1) + MTB(1,2)*MSUN(2,1) + 
     &           MTB(1,3)*MSUN(3,1)
      MHG(1,2) = MTB(1,1)*MSUN(1,2) + MTB(1,2)*MSUN(2,2) + 
     &           MTB(1,3)*MSUN(3,2)
      MHG(1,3) = MTB(1,1)*MSUN(1,3) + MTB(1,2)*MSUN(2,3) + 
     &           MTB(1,3)*MSUN(3,3)
C
      MHG(2,1) = MTB(2,1)*MSUN(1,1) + MTB(2,2)*MSUN(2,1) + 
     &           MTB(2,3)*MSUN(3,1)
      MHG(2,2) = MTB(2,1)*MSUN(1,2) + MTB(2,2)*MSUN(2,2) + 
     &           MTB(2,3)*MSUN(3,2)
      MHG(2,3) = MTB(2,1)*MSUN(1,3) + MTB(2,2)*MSUN(2,3) + 
     &           MTB(2,3)*MSUN(3,3)
C
      MHG(3,1) = MTB(3,1)*MSUN(1,1) + MTB(3,2)*MSUN(2,1) + 
     &           MTB(3,3)*MSUN(3,1)
      MHG(3,2) = MTB(3,1)*MSUN(1,2) + MTB(3,2)*MSUN(2,2) + 
     &           MTB(3,3)*MSUN(3,2)
      MHG(3,3) = MTB(3,1)*MSUN(1,3) + MTB(3,2)*MSUN(2,3) + 
     &           MTB(3,3)*MSUN(3,3)
C
      RETURN
      END
