
! script name: conics.d/sinecurve
! topic: construct sine curve through points

!A
!A NAME:
!A
!A 	Sine Curve
!A
!A DESCRIPTION:
!A
!A 	This script constructs a sine curve through points.
!A
!B INSTRUCTIONS:
!B
!B 	AMPLITUDE OF WAVE: Enter the amplitude of the sine curve.
!B
!B	LENGTH OF ONE CYCLE: The length in units off one complete cycle.
!B
!B 	CENTER POINT ABS X,Y: Enter the X,Y coordinates of the 0,0 point 
!B 		of the sine curve.  NOTE: See XYZ INPUT OPTIONS.
!B
!B 	STARTING ANGLE: Enter the starting angle of the curve.
!B
!B 	ANGULAR EXTENT: Enter the total number of degrees for the curve
!B 		construction.
!B
!# see also - points.d/xyzinput.hlp

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

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

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

Stat=SetEqualsValue(1,"")
Amplitude=GetValue("AMPLITUDE OF WAVE")
IF (ExitScript(Destination$)) THEN Leave

Stat=SetEqualsValue(2*PI)
Flen=GetValue("LENGTH OF ONE CYCLE")
IF (ExitScript(Destination$)) THEN Leave

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

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

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

Ang_inc=5
Nsteps= INT(ABS(Angle)/Ang_inc)+1
Ang_inc=Angle/Nsteps

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

PlotOff
FOR I=0 TO Nsteps
	Ang=Astart+I*Ang_inc
	X=Xcen+Flen*Ang/360
	Y=Ycen+Amplitude*SIN(Ang)
	Z=0

	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("sine curve")
Stat= AddItemToUndo(WsUBCreateMode,Spline_group)
GOTO Group_loop


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

