
! script name: circles.d/dirrad2pts
! topic: construct arc defined by end points and signed radius

!A
!A NAME:
!A
!A 	Signed Rad: Two Points
!A
!A DESCRIPTION:
!A
!A 	This script constructs an arc of known radius with the two end points
!A 	defined.
!A
!A~ image location - images/rad2points.jpg
!B INSTRUCTIONS:
!B
!B 	CIRCLE RADIUS, (+cw, -ccw): Enter radius of arc to be constructed.
!B 		Sign of radius determines direction.
!B
!B 	FIRST POINT ABS X,Y: Enter the X,Y coordinates of the first point,
!B 		which will be one of the end points of the arc constructed.
!B 		NOTE: See XYZ INPUT OPTIONS.
!B
!B 	NEXT POINT ABS X,Y: Enter the X,Y coordinates of the next point,
!B 		which will be the other end point of the arc constructed.
!B
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: rad: two points ")

DIM Destination$[256]
DIM Answer$[256]


DEG

ActivateUndo
stat= SetInputFormat("n4","")
Radius=InputRadius("CIRCLE RADIUS, (+ cw, -ccw) ",WsRadiusInput,WsSigned)
IF (ExitScript(Destination$)) THEN Leave

Circle_loop:!
ON ERROR GOTO Error_check
P1=XyzInput("FIRST POINT",WsXyOnly)
IF (ExitScript(Destination$)) THEN Leave

Point2: !
P2=XyzInput("NEXT POINT",WsXyOnly)
IF (ExitScript(Destination$)) THEN Leave

Ptdist=DistTwoPts(P1,P2)
IF Ptdist<.000098 THEN 
	Stat=DeleteEntity(P2)
	GOTO Point2
END IF

Dir1= (Radius> 0)- (Radius< 0)
C1=RadiusTwoPoints(Radius,P1,P2,Dir1)


Error_check: OFF ERROR
Stat=DeleteEntity(P1)
Stat=DeleteEntity(P2)

ActivateUndo
Stat= AdvanceUndoNumber("circle")
Stat= AddItemToUndo(WsUBCreateMode,C1)
GOTO Circle_loop

Leave:!
Stat=DeleteEntity(P1)
Stat=DeleteEntity(P2)

IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
