C     COPYRIGHT       NONE.  THIS CODE IS IN THE PUBLIC DOMAIN.
C     FILENAME        GEMINICATCHUPANDRENDEZVOUSPROGRAM/GANG.F
C     PURPOSE         THIS IS PART OF THE ORIGINAL 1965 SIMULATION
C                     PROGRAM FOR THE GEMINI 7/6 MISSION
C                     CATCH-UP AND RENDEZVOUS FLIGHT PHASES.
C                     THIS PARTICULAR FILE CONTAINS ONLY THE
C                     GANG SUBROUTINE (GIMBAL ANGLE SUBROUTINE FOR
C                     FLIP CORRECTION).
C     WEBSITE         WWW.IBIBLIO.ORG/APOLLO
C     HISTORY         2010-08-14 RSB  BEGAN TRANSCRIBING FROM
C                                     THE SCANNED PDF REPORT.
C
C     REFER TO MAIN.F FOR MORE-DETAILED INTRODUCTORY COMMENTS.
C
C     FROM PAGE 141 OF THE REPORT 
      SUBROUTINE GANG (CTHB,CPHIB,CPSIB,THETAB,PHIB,PSIB,CUDTHS,CUDPSS,
     1CUDPHS,CTHBC,CPSIBC)
      CTHB=THETAB
      CPSIB=PSIB
      CPHIB=PHIB
101   IF (1.57079633-CPSIB) 102,99,99
102   IF (CPSIB-4.71238898) 103,99,99
103   CPSIB=3.14159265-CPSIB
104   IF (CPSIB) 105,106,106
105   CPSIB=CPSIB+6.28318530
106   IF (3.14159265-CTHB) 108,107,107
107   CTHB=CTHB+3.14159265
      GO TO 109
108   CTHB=CTHB-3.14159265
109   IF (3.14159265-CPHIB) 111,110,110
110   CPHIB=CPHIB+3.14159265
      GO TO 99
111   CPHIB=CPHIB-3.14159265
99    CUDPHS=CPHIB
      CUDTHS=CTHB-CTHBC
      CUDPSS=CPSIB-CPSIBC
50    IF (ABSF(CUDPHS)-3.14159265) 60,51,51
51    IF (CUDPHS) 52,53,53
52    CUDPHS=CUDPHS+6.28318530
      GO TO 60
53    CUDPHS=CUDPHS-6.28318530
60    IF (ABSF(CUDPSS)-3.14159265) 70,61,61
61    IF (CUDPSS) 62,63,63
62    CUDPSS=CUDPSS+6.28318530
      GO TO 70
63    CUDPSS=CUDPSS-6.28318530
70    IF (ABSF(CUDTHS)-3.14159265) 74,71,71
71    IF (CUDTHS) 72,73,73
72    CUDTHS=CUDTHS+6.28318530
      GO TO 74
73    CUDTHS=CUDTHS-6.28318530
74    RETURN
      END(1,1,0,0,0,0,1,1,0,0,0,0,0,0,0)
