
! script name: conics.d/hyperbola
! topic: construct spline curve through hyperbola

!A
!A NAME:
!A
!A 	Hyperbola
!A
!A DESCRIPTION:
!A
!A 	This script constructs a spline curve through a Hyperbola.
!A
!B INSTRUCTIONS:
!B	
!B	(X/A)^2- (Y/B)^2= 1
!B
!B 	A: Enter the A coefficient
!B
!B 	B: Enter the B coefficient
!B
!B	ANGLE: Enter the orientation angle.
!B
!B	LENGTH: Enter the Length.
!B

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

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

ActivateUndo
Stat=SetInputFormat("n4","")
Length1=GetDefault(WsLineLength)
Num_pts=50
A=5
B=5

Group_loop:!
Group=CreateGroup("TEMPGROUP")
Pt_count=1

Stat=SetInputFormat("n4=","")
Stat=SetEqualsValue(A)
A=GetValue("A ",Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF A< 0.0001 THEN Leave

Stat=SetEqualsValue(B)
B=GetValue("B ",Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF B< 0.0001 THEN Leave

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


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

Stat=SetEqualsValue(Length1)
Length1=GetValue("LENGTH ",Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF Length1< 0.0001 THEN Leave

Stat=SetEqualsValue(Num_pts)
Num_pts=GetValue("NUMBER OF POINTS ",Answer$)
IF (ExitScript(Destination$)) THEN Leave

IF Num_pts< 5 THEN Num_pts= 5


Nsteps= Num_pts-1

Xcen= 0.0
Ycen= 0.0
Zcen= 0.0
Astart= 0.0

DEG

Xcen= XPointValue(Pc)
Ycen= YPointValue(Pc)
Zcen= ZPointValue(Pc)

PlotOff
FOR I=0 TO Nsteps
	T1= I/Nsteps
	Y1= -Length1/2+ T1*Length1
	X1= A*SQR(ABS(1.0+ (Y1*Y1)/(B*B)))  
	X= Xcen+ X1*COS(Angle)- Y1*SIN(Angle)
	Y= Ycen+ X1*SIN(Angle)+ Y1*COS(Angle)
	Z= Zcen

	Pt= PointXYZ(X,Y,Z)

	Stat=AddToGroup(Group,Pt)

	Pt_count=Pt_count+1
NEXT I

Spline_group=CSCurvePtGrp(Group,Pt,0,Pt,0)
Stat=DeleteGroup(Group)
Stat=DeleteEntity(Center)
Stat=DeleteEntity(Pc)
PlotOn
Stat=PlotEntity(Spline_group)
ActivateUndo
Stat= AdvanceUndoNumber("hyperbola")
Stat= AddItemToUndo(WsUBCreateMode,Spline_group)
GOTO Group_loop


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

