
! script name: circles.d/dyncenterpoint
! topic: construct circle defined by center and tangent point

!A
!A NAME:
!A
!A 	Dynamic Center: Point
!A
!A DESCRIPTION:
!A
!A 	This script constructs a circle of unknown radius about a point
!A 	tangent to a known point.
!A
!A~ image location - images/centerandpoint.jpg
!B INSTRUCTIONS:
!B
!B
!C NOTES:
!C
!C 	The dynamic input mode is an option that may be turned off by
!C 	setting the variable "Grapical mode=0".  To set the variable,
!C 	under "Settings", select "Variables".  The selection box will appear
!C 	at this time.  Select "Graphical mode=1" and change the
!C 	setting to "0".  The dynamic input mode is the default whenever
!C 	Synergy is started.  This change is for this session of Synergy
!C 	only.
!C
!C 	The dynamic input mode may be turned off for future sessions of
!C 	Synergy by going to "Settings" and selecting "Constants".  The editor
!C 	will bring up the setconstants script.  The following line needs
!C 	to be modified (the 1.0 needs to be changed to 0.0):
!C
!C 		V10=CreateVariable("Graphical mode",WsSystemVars,1.0)
!C
!C 	to:
!C
!C 		V10=CreateVariable("Graphical mode",WsSystemVars,0.0)
!C
!C 	The line is near the middle of the script.
!C
!# see also - points.d/dyninput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: dynamic center: point ")

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


Graphical_mode=NamedVarVal("Graphical mode",WsSystemVars,1.0)

Start:!
DEG

ActivateUndo
Circle_loop:!
stat= SetInputFormat("n4b","")
Pc=XyzInput("INPUT CENTER",WsXyOnly)
IF (ExitScript(Destination$)) THEN Leave


IF NOT Graphical_mode THEN 
stat= SetInputFormat("n4b","")
Pt=XyzInput("INPUT POINT",WsXyzInput)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Pt) THEN Circle_loop

Radius= DistTwoPts(Pc,Pt)
C1= RadiusCenter(Radius,Pc)

ELSE
PlotOff
C1= RadiusCenter(1.0,Pc)
Pt= ParameterPt(C1,0.0)
Stat= MakeInvisible(C1)
Stat= MakeInvisible(Pt)
PlotOn

Vnum= LastPickView
stat= SetInputFormat("n4b","")
Stat=DynamicEntity(Vnum,C1,Pc,Pt,WsDynamicRadius)
IF (ExitScript(Destination$)) THEN
        Stat=DeleteEntity(C1,WsTrue)
        GOTO Leave
END IF
END IF
Stat=DeleteEntity(Pt)
Stat=DeleteEntity(Pc)
Stat= MakeVisible(C1)
Stat= PlotEntity(C1)

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


Leave:!
stat= SetInputFormat("n4","")
Stat=DeleteEntity(Pt)
Stat=DeleteEntity(Pc)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	IF Destination$= "SCRIPTSTART" THEN Start
        IF Destination$= "BACKUP" THEN Start
	LOAD Destination$
END IF
END
