C 
C 
C                   FIRST PRINTING, FEBRUARY 1974
C 
C THE INFORMATION IN THIS DOCUMENT IS SUBJECT TO 
C CHANGE WITHOUT NOTICE AND SHOULD NOT BE CONSTRUED
C AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION.
C DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPON-
C SIBILITY FOR ANY ERRORS THAT MAY APPEAR IN THIS
C DOCUMENT.
C 
C THE SOFTWARE DESCRIBED IN THIS DOCUMENT IS FUR-
C NISHED TO THE PURCHASER UNDER A LICENSE FOR USE ON
C A SINGLE COMPUTER SYSTEM AND CAN BE COPIED (WITH
C INCLUSION OF DIGITAL'S COPYRIGHT NOTICE) ONLY FOR 
C USE IN SUCH SYSTEM, EXCEPT AS MAY OTHERWISE BE PRO-
C VIDED IN WRITING BY DIGITAL.
C 
C DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPONSIBILITY
C FOR THE USE OR RELIABILITY OF ITS SOFTWARE ON EQUIP-
C MENT THAT IS NOT SUPPLIED BY DIGITAL.
C 
C COPYRIGHT (C) 1974, BY DIGITAL EQUIPMENT CORPORATION
C 
C 
C
C  TITLE  CIRCLE
COPYRIGHT 1973, DIGITAL EQUIPMENT CORP. , MAYNARD MASS.
C
	SUBROUTINE CIRCLE (R,THETA,GAMMA,ANG,ISUB)
C
C  WHERE R IS THE RADIUS OF THE CIRCLE IN FLOATING POINT
C    RASTER UNITS
C  WHERE THETA IS THE STARTING ANGLE IN FLOATING POINT DEGREES
C  WHERE GAMMA IS THE ENDING ANGLE IN FLOATING POINT DEGREES
C  WHERE ANG  IS THE ANGLE SUBTENDED BY EACH SIDE OF THE
C    POLYGON IN FLOATING POINT DEGREES
C  WHERE ISUB IS THE NAME OF THE SUBPICTURE FILE WHICH WILL 
C    CONTAIN THE CIRCLE. PREVIOUS CONTENTS OF ISUB ARE LOST!
C
C  IF ANG IS LESS THAN .001 DEGREE ABSOLUTE, NO ACTION IS TAKEN
C  IF R IS LESS THAN ONE RASTER, NO ACTION IS TAKEN
C  IT IS POSSIBLE FOR THE ROUTINE TO APPROXIMATE AN ARC OF
C    CIRCLE WITH ONLY A ONE-SIDED POLYGON.
C  IF THE STARTING AND ENDING ANGLES ARE LESS THAN .001 DEGREE
C    APART (MODULO 360.), A FULL CIRCLE IS DRAWN.
C  CIRCLES CAN BE DRAWN BACKWARDS (I.E. NEGATIVE ANG)
C  LARGE DIFFERENCES IN GAMMA-THETA ARE REDUCED MODULO 360.
C  THE MAXIMUM NUMBER OF POLYGON SIDES ALLOWED IS 360
C
C  NOTE A DIFFERENCE FROM THE PREVIOUS ROUTINE. THE BEAM IS
C  RETURNED TO ITS ORIGINAL POSITION IN ALL CASES!
C
	DIMENSION ISUB(1)
C
C  CONVERT TO RADIANS
C
	ATHETA=THETA/57.2958
	AANG=ANG/57.2958
C
C  LIMIT CHECKS
C
	IF(ANG.GT.0.001) GO TO 2
	IF(ANG.LT.-0.001) GO TO 2
	RETURN
 2	IF(R.LT.1.0) RETURN
C
C  REDUCE GAMMA-THETA MOD 360
C
	A=(GAMMA-THETA)/360.
	IA=A
	A=IA
	DEL=GAMMA-THETA-A*360.
C
C  CONTROL COUNT FOR NUMBER OF SIDES ON POLYGON
C
	CC=DEL/ANG
C
C  IF TOO SMALL, NEED ANOTHER MOD 360
C
	IF(CC.LT.0.001) CC=CC+360./ANG
C
C  ROUND UP TO INTEGER
C
	ICC=CC+0.999
C
C  CONTROL SIZE
C
	IF(ICC.LT.1) RETURN
	IF(ICC.GT.360)  ICC=360
C
C  REINIT SUBPICTURE FILE
C
	ISUB(1)=0
C
C  DX AND DY FOR RADIAL DISPLACEMENT TO EDGE OF CIRCLE
C
	IX1=R*COS(ATHETA)
	IY1=R*SIN(ATHETA)
	CALL LINE (IX1,IY1,0,ISUB(1))
C
C  LOOP TO CREATE POLYGON
C
	DO 100 I=1,ICC
	ATHETA=ATHETA+AANG
C
C  NEW END POINT
C
	IX2=R*COS(ATHETA)
	IY2=R*SIN(ATHETA)
C
C  DX AND DY FOR SIDE OF POLYGON
C
	IDX=IX2-IX1
	IDY=IY2-IY1
	CALL LINE (IDX,IDY,1)
C
C  REMMEMBER PRESENT END POINT
C
	IX1=IX2
	IY1=IY2
 100	CONTINUE
C
C  REPLACE BEAM TO CENTER OF CIRCLE
C
	CALL LINE (-IX2,-IY2,0)
	RETURN
	END
