
! script name: conics.d/parabola
! topic: create parabola defined by focus and vertex

!A
!A NAME:
!A
!A 	Parabola (vertex, focus)
!A
!A DESCRIPTION:
!A
!A 	This script creates a parabola with known focus and known vertex.
!A 	A parabola is the locus of points such that any point on the parabola
!A 	is equidistant from a fixed point, called the focus, and a fixed line,
!A 	called the directrix.
!A
!A~ image location - images/parabola.jpg
!B INSTRUCTIONS:
!B
!B 	VERTEX POINT ABS X,Y: Enter the X,Y coordinates of the vertex of the
!B 		parabola.  NOTE: See XYZ INPUT OPTIONS.
!B
!B 	FOCUS POINT ABS X,Y: Enter the X,Y coordinates of the focus point of
!B 		the parabola.
!B
!C NOTES:
!C
!C 	The standard equation of a parabola with focus at (0,P) and directrix
!C 	at Y=-P is:
!C
!C 		X^2=4PY
!C
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: parabola (vertex, focus) ")

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

ActivateUndo
Length=GetDefault(WsLineLength)

Stat=DynLabel("Length:"&VAL$(Length))
Stat=SetInputFormat("n4","")
Parabola_loop:Vertex=XyzInput("VERTEX POINT",WsXyzInput)
IF (ExitScript(Destination$)) THEN Leave

Stat=SetLastPoint(Vertex)
Focus=XyzInput("FOCUS POINT",WsXyzInput)
IF (ExitScript(Destination$)) THEN Leave


Length= DynBufferValue(0,Length)
P1=Parabola(Vertex,Focus,0.5*Length)

Stat=SetLastPoint(Focus)
Stat=DeleteEntity(Vertex)
Stat=DeleteEntity(Focus)
ActivateUndo
Stat= AdvanceUndoNumber("parabola")
Stat= AddItemToUndo(WsUBCreateMode,P1)

GOTO Parabola_loop

Leave:!
Stat= DynLabel("")
Stat=DeleteEntity(Vertex)
Stat=DeleteEntity(Focus)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
