      SUBROUTINE ALG18 (BETA1,BETA2,I1,I2,FACT,X0,Y0,S0,XR,Y1,X1,Y2,RDI
     1US,S,C1)
C
      DIMENSION S(80)
C
      DELX=XR/FLOAT(I2-I1)
      XX=X0
      I3=I1+1
      IF (BETA1.EQ.BETA2) GO TO 20
      Y1=-COS(BETA1/C1)/(SIN(BETA1/C1)-SIN(BETA2/C1))
      X1=SIN(BETA1/C1)/(SIN(BETA1/C1)-SIN(BETA2/C1))
      Y2=TAN((BETA1+BETA2)/(2.0*C1))
      RDIUS=ABS(1.0/(SIN(BETA1/C1)-SIN(BETA2/C1)))
      Y2=Y2*FACT+Y0
      Y1=Y1*FACT+Y0
      X1=X1*FACT+X0
      RDIUS=RDIUS*FACT
      DO 10 J=I3,I2
      XX=XX+DELX
      PHI1=ATAN(-1./SQRT(RDIUS**2-(XX-X1)**2)*(XX-X1))
      IF ((BETA1-BETA2).LT.0.0) PHI1=-PHI1
      PHI2=ABS(BETA1/C1-PHI1)
10    S(J)=RDIUS*PHI2+S0
      RETURN
20    AM=TAN(BETA1/C1)
      DO 30 J=I3,I2
      XX=XX+DELX
30    S(J)=(XX-X0)*SQRT(AM*AM+1.0)+S0
      Y2=AM*(XX-X0)+Y0
      RETURN
      END
