**==mtx_rotate.f  
C++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C
      SUBROUTINE  MTX_ROTATE (ANGLES, ROT_MAT)
C
C Purpose: To generate a rotation matrix given three angles in degrees
C          The order of rotations is given by the order of the angles
C          in the vector. A 3D orthogonal space is assumed.
C
C      IMPLICIT NONE
C
      REAL  ANGLES(3), ROT_MAT(3,3)
C
C-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
C Local Variables:
C
      REAL  CX(3,3), CY(3,3), CZ(3,3), C(3,3)
      REAL  CPX, SPX, CPY, SPY, CPZ, SPZ
      REAL  DEG_TO_RAD
C
C------------------------------------------------------------------------------
C
      DEG_TO_RAD = 3.1415926536/180.0
C
      CPX = COS(ANGLES(1)*DEG_TO_RAD)
      SPX = SIN(ANGLES(1)*DEG_TO_RAD)
      CPY = COS(ANGLES(2)*DEG_TO_RAD)
      SPY = SIN(ANGLES(2)*DEG_TO_RAD)
      CPZ = COS(ANGLES(3)*DEG_TO_RAD)
      SPZ = SIN(ANGLES(3)*DEG_TO_RAD)
C
      CALL MTX_ZERO(CX,3,3)
      CX(1,1) = 1.0
      CX(2,2) = CPX
      CX(2,3) = -SPX
      CX(3,2) = SPX
      CX(3,3) = CPX
C
      CALL MTX_ZERO(CY,3,3)
      CY(1,1) = CPY
      CY(1,3) = SPY
      CY(2,2) = 1.0
      CY(3,1) = -SPY
      CY(3,3) = CPY
C
      CALL MTX_ZERO(CZ,3,3)
      CZ(1,1) = CPZ
      CZ(1,2) = -SPZ
      CZ(2,1) = SPZ
      CZ(2,2) = CPZ
      CZ(3,3) = 1.0
C
      CALL MTX_MULT(CY,CX,C,3,3,3)
      CALL MTX_MULT(CZ,C,ROT_MAT,3,3,3)
C
      RETURN
      END
