
! script name: conics.d/ellipse
! topic: create an ellipse

!A
!A NAME:
!A
!A 	Ellipse
!A
!A DESCRIPTION:
!A
!A 	This script creates an ellipse.  An ellipse is the locus of points
!A 	such that the sum of the distances from any point on the ellipse to
!A 	two fixed points, the foci, is a constant.
!A
!B INSTRUCTIONS:
!B
!B 	SEMI MAJOR AXIS: Enter the distance from the center of the ellipse
!B 		to a vertex.
!B
!B 	SEMI MINOR AXIS: Enter the distance from the center of the ellipse
!B 		to a vertex perpendicular to the major axis.
!B
!B 	ELLIPSE CENTER ABS X,Y,Z: Enter the X,Y,Z coordinates of the center
!B 		of the ellipse.  NOTE: See XYZ INPUT OPTIONS.
!B
!B 	ORIENTATION ANGLE: Enter the angle the ellipse is to be oriented.
!B
!C NOTES:
!C
!C 	The standard equation of an ellipse is:
!C
!C 		X^2/A^2+Y^2/B^2=1
!C
!C 	The location of the foci may be calculated using:
!C
!C 		C^2=A^2-B^2    when A>B
!C
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: ellipse ")

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

DEG

ActivateUndo
Ellipse_loop:Stat=SetInputFormat("n4=","")
Stat=SetEqualsValue(A)
A=GetValue("SEMI MAJOR AXIS",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Stat=SetEqualsValue(B)
B=GetValue("SEMI MINOR AXIS",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Stat=SetInputFormat("n4a1=",",I,A,")
Stat=SetPickReturn(WsGeomCenter)
Pc=XyzInput("ELLIPSE CENTER",WsXyzInput)
IF (ExitScript(Destination$)) THEN Leave

Stat=SetInputFormat("n4=","")
Stat=SetEqualsValue(Angle)
Angle=InputAngle("ORIENTATION ANGLE")
IF (ExitScript(Destination$)) THEN Leave

E1=Ellipse(A,B,Pc,0,360,Angle)


Stat=SetLastPoint(Pc)
Stat=DeleteEntity(Pc)

ActivateUndo
Stat= AdvanceUndoNumber("ellipse")
Stat= AddItemToUndo(WsUBCreateMode,E1)

GOTO Ellipse_loop

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