     	SUBROUTINE IFARCS(XOP,YOP,RAD1,RAD2,RAD3,ANGL0,ANGL1,ANGL2,ANGL3)
C
C  PROGRAMMER: R.S. ZHOU	MARCH-1986
C
C	THIS ROUTINE DRAWS AN ARC/CIRCLE/ELLIPSE/PIE/DONUN.
C
C	XOP ------ X-COORDINATE OF THE CENTER IN INCHES.
C	YOP ------ Y-COORDINATE OF THE CENTER IN INCHES.
C	RAD1 ----- RADIUS IN X-DIMENSION IN INCHES.
C	RAD2 ----- RADIUS IN Y-DIMENSION IN INCHES.
C	RAD3 ----- BORDER WIDTH (INWARD) IN INCHES.
C		   IF BORDER=RADIUS, A PIE IS DRAWN.
C	ANGL0 ---- ROTATION ANGLE OF OBJECT IN DEGREES FROM X-AXIS.
C	ANGL1 ---- STARTING ANGLE IN DEGREES TO DRAW THE ARC.
C	ANGL2 ---- ADDITIVE ANGLE IN DEGREES TO ANG1.
C	ANGL3 ---- CHORD ANGLE IN DEGREES [10.0].
C
     	INCLUDE  'TEKLIB.CBS'
     	LOGICAL   PIE

     	IF( ABS(RAD1).LT.0.01 .OR. ABS(RAD2).LT.0.01 ) RETURN
     	IWD = IDW
     	IF( ITM.EQ.1 ) GOTO 888
C
C  INITIALIZE...
C
     	IDW = 0
     	XPS = XOP
     	YPS = YOP
     	RD1 = ABS(RAD1)
     	RD2 = ABS(RAD2)
     	RD3 = ABS(RAD3)
     	ANG0 = AMOD( ANGL0, 360.0 )
     	ANG1 = AMOD( ANGL1, 360.0 )
     	ANG2 = AMOD( ANGL2, 360.0 ) + ANG1
     	CHORD = 10.0
     	IF( ANGL3.NE.0.0 ) CHORD = ABS(ANGL3)
     	IF( ANG1.EQ.ANG2 ) THEN
     	    ANG1 = 0.0
     	    ANG2 = 360.
     	ENDIF
     	IF( ANG1.GT.ANG2 ) THEN
     	    ANGLE = ANG1
     	    ANG1  = ANG2
     	    ANG2  = ANGLE
     	ENDIF
     	IF( CHORD.GT.(ANG2-ANG1) ) CHORD = 0.5*(ANG2-ANG1)
     	PIE = .FALSE.
     	IF( RD3.GE.RD1 .OR. RD3.GE.RD2 ) THEN
     	    RD3 = 0.0
     	    IF( (ANG2-ANG1).LT.360.0 ) PIE = .TRUE.
     	ENDIF
C
C  MOVE ORIGIN TO (XPS,YPS) ...
C
     	CALL IFPLOT( XPS, YPS, -9 )
     	CALL IFPLOT( 0.0, 0.0,  3 )
C
C  SET ROTATION IT AT ALL...
C
    	IF( ANG0.NE.0.0 ) THEN
     	    ANGX = XANG
     	    ANGY = YANG
     	    CALL IFROTA( ANG0+XANG, ANG0+YANG )
     	ENDIF
C
C  START THE DRAWING...
C
     	LOOP = 1
     	IF( RD3.GT.0 ) LOOP = 2
     	DO I = 1, LOOP
     	    IF( I.EQ.1 ) THEN
     		ANG11 = ANG1
     		ANG22 = ANG2
     		ANGIN = CHORD
     	    ELSE
     		ANG11 = ANG2
     		ANG22 = ANG1
     		ANGIN = -CHORD
     		RD1 = RD1 - RD3
     		RD2 = RD2 - RD3
     	    ENDIF
     	    RDD = 1.0/(RD1*RD1)
     	DO  ANGLE = ANG11, ANG22, ANGIN
     	    XPS = RD1*COS(ANGLE*D2R)
     	    YPS = 1.0 - XPS*XPS*RDD
     	    IF( YPS.GT.0 ) THEN
     		YPS = RD2*SQRT(YPS)
     	    ELSE
     		YPS = 0.0
     	    ENDIF
     	    IF( ANGLE.GT.180.0 .OR. ANGLE.LT.0.0 ) YPS = -YPS
     	    IF( ANGLE.NE.ANG11 ) THEN
     		CALL IFPLOT( XPS, YPS, 2 )
     	    ELSE
     		IF( I.EQ.1 ) THEN
     		    IF( PIE ) THEN
     			CALL IFPLOT( 0.0, 0.0, 3 )
     			CALL IFPLOT( XPS, YPS, 2 )
     		    ELSE
     		    	CALL IFPLOT( XPS, YPS, 3 )
     		    ENDIF
     		    XPSL = XPS
     		    YPSL = YPS
     		ELSE
     		    IF( (ANG2-ANG1).LT.360.0 ) THEN
     			CALL IFPLOT( XPS, YPS, 2 )
     		    ELSE
     			CALL IFPLOT( XPS, YPS, 3 )
     		    ENDIF
     		ENDIF
     	    ENDIF
     	ENDDO
     	ENDDO
     	IF(LOOP.EQ.2.AND.(ANG2-ANG1).LT.360.) CALL IFPLOT(XPSL,YPSL,2)
C
C  RESTORE...
C
     	IF( PIE ) CALL IFPLOT( 0.0, 0.0, 2 )
     	IF( ANG0.NE.0.0 ) CALL IFROTA( ANGX, ANGY )
     	CALL IFPLOT( -XOP, -YOP, -9 )

888	IF( IWD.NE.0 ) THEN
     	    IF( NPPS.GT.0 ) CALL IFPLOT_DUMP
     	    WRITE(IDF,1000) RAD1,RAD2,RAD3, XOP,YOP,
     +                      ANGL0,ANGL1,ANGL2,ANGL3
     	ENDIF
1000	FORMAT('ARCS:',9F8.3)
     	IDW = IWD

999	RETURN
    	END

