
! script name: conics.d/parabola2
! topic: create parabola using formula

!A
!A NAME:
!A
!A 	Parabola (equation)
!A
!A DESCRIPTION:
!A
!A 	This script creates a parabola using the formula for a parabola:
!A
!A 		Y= AX^2+ BX+ C
!A
!B INSTRUCTIONS:
!B
!B 	A: Enter the value to be used for the A constant.
!B
!B 	B: Enter the value to be used for the B constant.
!B
!B 	C: Enter the value to be used for the C constant.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: parabola (equation) ")

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

ActivateUndo
Stat=SetInputFormat("n4","")

Parabola_loop:A=GetValue("A",Answer$)
IF (ExitScript(Destination$)) THEN Leave

B=GetValue("B",Answer$)
IF (ExitScript(Destination$)) THEN Leave

C=GetValue("C",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Length=5.0

X0=-B/(2*A)
Y0=(4*A*C-B*B)/(4*A)
Z0=0
P=1.0/(4*A)

Vertex=PointXYZ(X0,Y0,Z0)
Focus=PointXYZ(X0,Y0+P,Z0)

P1=Parabola(Vertex,Focus,Length)

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

GOTO Parabola_loop

Leave:!

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