      SUBROUTINE KURVP2 (T,XS,YS,N,X,Y,XP,YP,S,SIGMA)
C
      INTEGER N
      REAL T,XS,YS,X(N),Y(N),XP(N),YP(N),S(N),SIGMA
C
C                      FROM THE SPLINE UNDER TENSION PACKAGE
C                       CODED BY A. K. CLINE AND R. J. RENKA
C                            DEPARTMENT OF COMPUTER SCIENCES
C                              UNIVERSITY OF TEXAS AT AUSTIN
C
C THIS SUBROUTINE PERFORMS THE MAPPING OF POINTS IN THE
C INTERVAL (0.,1.) ONTO A CLOSED CURVE IN THE PLANE. THE
C SUBROUTINE KURVP1 SHOULD BE CALLED EARLIER TO DETERMINE
C CERTAIN NECESSARY PARAMETERS. THE RESULTING CURVE HAS A
C PARAMETRIC REPRESENTATION BOTH OF WHOSE COMPONENTS ARE
C PERIODIC SPLINES UNDER TENSION AND FUNCTIONS OF THE POLY-
C GONAL ARCLENGTH PARAMETER.
C
C ON INPUT--
C
C   T CONTAINS A VALUE TO BE MAPPED ONTO THE CURVE. THE
C   INTERVAL (0.,1.) IS MAPPED ONTO THE ENTIRE CLOSED CURVE
C   WITH BOTH 0. AND 1. MAPPING TO (X(1),Y(1)). THE MAPPING
C   IS PERIODIC WITH PERIOD ONE THUS ANY INTERVAL OF THE
C   FORM (TT,TT+1.) MAPS ONTO THE ENTIRE CURVE.
C
C   N CONTAINS THE NUMBER OF POINTS WHICH WERE SPECIFIED
C   TO DETERMINE THE CURVE.
C
C   X AND Y ARE ARRAYS CONTAINING THE X- AND Y-COORDINATES
C   OF THE SPECIFIED POINTS.
C
C   XP AND YP ARE THE ARRAYS OUTPUT FROM KURVP1 CONTAINING
C   CURVATURE INFORMATION.
C
C   S IS AN ARRAY CONTAINING THE POLYGONAL ARCLENGTHS OF
C   THE CURVE.
C
C AND
C
C   SIGMA CONTAINS THE TENSION FACTOR (ITS SIGN IS IGNORED).
C
C THE PARAMETERS N, X, Y, XP, YP, S AND SIGMA SHOULD
C BE INPUT UNALTERED FROM THE OUTPUT OF KURVP1.
C
C ON OUTPUT--
C
C   XS AND YS CONTAIN THE X- AND Y-COORDINATES OF THE IMAGE
C   POINT ON THE CURVE.
C
C NONE OF THE INPUT PARAMETERS ARE ALTERED.
C
C THIS SUBROUTINE REFERENCES PACKAGE MODULES INTRVL AND
C SNHCSH.
C
C-----------------------------------------------------------
C
C DETERMINE INTERVAL
C
      TN = T-FLOAT(IFIX(T))
      IF (TN .LT. 0.) TN = TN+1.
      TN = S(N)*TN+S(1)
      IM1 = N
      IF (TN .LT. S(N)) IM1 = INTRVL(TN,S,N)
      I = IM1+1
      IF (I .GT. N) I = 1
C
C DENORMALIZE TENSION FACTOR
C
      SIGMAP = ABS(SIGMA)*FLOAT(N)/S(N)
C
C SET UP AND PERFORM INTERPOLATION
C
      SI = S(I)
      IF (IM1 .EQ. N) SI = S(N)+S(1)
      DEL1 = TN-S(IM1)
      DEL2 = SI-TN
      DELS = SI-S(IM1)
      SUMX = (X(I)*DEL1+X(IM1)*DEL2)/DELS
      SUMY = (Y(I)*DEL1+Y(IM1)*DEL2)/DELS
      IF (SIGMAP .NE. 0.) GO TO 1
      D = DEL1*DEL2/(6.*DELS)
      C1 = (DEL1+DELS)*D
      C2 = (DEL2+DELS)*D
      XS = SUMX-XP(I)*C1-XP(IM1)*C2
      YS = SUMY-YP(I)*C1-YP(IM1)*C2
      RETURN
    1 DELP1 = SIGMAP*(DEL1+DELS)/2.
      DELP2 = SIGMAP*(DEL2+DELS)/2.
      CALL SNHCSH(SINHM1,DUMMY,SIGMAP*DEL1,-1)
      CALL SNHCSH(SINHM2,DUMMY,SIGMAP*DEL2,-1)
      CALL SNHCSH(SINHMS,DUMMY,SIGMAP*DELS,-1)
      CALL SNHCSH (SINHP1,DUMMY,SIGMAP*DEL1/2.,-1)
      CALL SNHCSH (SINHP2,DUMMY,SIGMAP*DEL2/2.,-1)
      CALL SNHCSH (DUMMY,COSHP1,DELP1,1)
      CALL SNHCSH (DUMMY,COSHP2,DELP2,1)
      D = SIGMAP*SIGMAP*DELS*(SINHMS+SIGMAP*DELS)
      CI = (SINHM1*DEL2-DEL1*(2.*(COSHP1+1.)*SINHP2+SIGMAP*
     *     COSHP1*DEL2))/D
      CIM1 = (SINHM2*DEL1-DEL2*(2.*(COSHP2+1.)*SINHP1+
     *       SIGMAP*COSHP2*DEL1))/D
      XS = SUMX+CI*XP(I)+CIM1*XP(IM1)
      YS = SUMY+CI*YP(I)+CIM1*YP(IM1)
      RETURN
      END
