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

!A
!A NAME:
!A
!A 	Spiral
!A
!A DESCRIPTION:
!A
!A 	This script constructs a spline curve through a spiral.
!A
!B INSTRUCTIONS:
!B
!B 	STARTING RADIUS OF SPIRAL: Enter the starting radius of the spiral
!B 		to be constructed.
!B
!B 	ENDING RADIUS OF SPIRAL: Enter the ending radius of the spiral to
!B 		be constructed.
!B
!B 	CENTER POINT ABS X,Y,Z: Enter the X,Y,Z coordinates of the center
!B 		point of the spiral.  NOTE: See XYZ INPUT OPTIONS.
!B
!B 	STARTING ANGLE: Enter the starting angle of the spiral.
!B
!B 	ANGULAR EXTENT: Enter the total number of degrees for the spiral
!B 		construction.
!B
!B 	Z START: Enter the Z coordinate of the start point of the spiral.
!B
!B 	Z END: Enter the Z coordinate of the end point of the spiral.
!B
!# see also - points.d/xyzinput.hlp

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

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

ActivateUndo
Group_loop:!
Stat=SetInputFormat("n4","")
Group=CreateGroup("TEMPGROUP")
Pt_count=1

Start_rad=InputRadius("STARTING RADIUS OF SPIRAL")
IF (ExitScript(Destination$)) THEN Leave

End_rad=InputRadius("ENDING RADIUS OF SPIRAL")
IF (ExitScript(Destination$)) THEN Leave

Center=XyzInput("CENTER POINT",WsXyzInput)
IF (ExitScript(Destination$)) THEN Leave

Astart=InputAngle("STARTING ANGLE")
IF (ExitScript(Destination$)) THEN Leave

Angle=InputAngle("ANGULAR EXTENT")
IF (ExitScript(Destination$)) THEN Leave

Zstart=GetValue("Z START",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Zend=GetValue("Z END",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Ang_inc=20
Nsteps=ABS(Angle)/Ang_inc+1
Ang_inc=Angle/Nsteps
Delz=(Zend-Zstart)/Nsteps
Delr=(End_rad-Start_rad)/Nsteps

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

PlotOff
FOR I=0 TO Nsteps
	Ang=Astart+I*Ang_inc
	Radius=Start_rad+I*Delr
	X=Xcen+Radius*COS(Ang)
	Y=Ycen+Radius*SIN(Ang)
	Z=Zstart+I*Delz

	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(Pt)
PlotOn
Stat=PlotEntity(Spline_group)
ActivateUndo
Stat= AdvanceUndoNumber("spirial")
Stat= AddItemToUndo(WsUBCreateMode,Spline_group)
GOTO Group_loop


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

