C/

C/COPYRIGHT (C) 1975

C/DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.

C/

C/THIS SOFTWARE IS FURNISHED UNDER A LICENSE FOR USE ONLY

C/ON A SINGLE COMPUTER SYSTEM AND MAY BE COPIED ONLY WITH

C/THE INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS

C/SOFTWARE, OR ANY OTHER COPIES THEREOF, MAY NOT BE PRO-

C/VIDED OR OTHERWISE MADE AVAILABLE TO ANY OTHER PERSON

C/EXCEPT FOR USE ON SUCH SYSTEM AND TO ONE WHO AGREES TO

C/THESE LICENSE TERMS.  TITLE TO AND OWNERSHIP OF THE

C/SOFTWARE SHALL AT ALL TIMES REMAIN IN DEC.

C/

C/THE INFORMATION IN THIS DOCUMENT IS SUBJECT TO CHANGE

C/WITHOUT NOTICE AND SHOULD NOT BE CONSTRUED AS A COM-

C/MITMENT BY DIGITAL EQUIPMENT CORPORATION.

C/

C/DEC ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY

C/OF ITS SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DEC.

C

C  TITLE  CIRCLE

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
