
! script name: 3dmacros.d/helicalsurf
! EXAMPLE: construct cubic spline between two concentric helicies

!A
!A NAME:
!A
!A 	Helical Surface
!A
!A DESCRIPTION:
!A
!A 	This script constructs a cubic spline surface between two concentric
!A 	helicies.
!A
!B INSTRUCTIONS:
!B
!B 	RADIUS OF HELIX: Enter the radius of the
!B 		helix to be constructed.
!B
!B 	CENTER POINT ABS X,Y: Enter the X,Y coordinates of
!B 		the center point of the helix.
!B 		NOTE: See XYZ INPUT OPTIONS.
!B
!B	STARTING ANGLE: Enter the starting angle of the helix.
!B
!B 	ANGULAR EXTENT: Enter the total number of degrees
!B 		for the helix construction.
!B
!B 	Z START: Enter the Z coordinate of the
!B 		 start point of the helix.
!B
!B 	Z END: Enter the Z coordinate of the
!B 		end point of the helix.
!B
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: helical surface ")

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

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

Stat=SetInputFormat("n4","")

Radius1=InputRadius("INNER RADIUS OF HELICAL SURFACE")
IF (ExitScript(Destination$)) THEN Leave

Radius2=InputRadius("OUTER RADIUS OF HELICAL SURFACE")
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


Point_loop:!

DEG

Ang_inc=10
Nsteps=ABS(Angle)/Ang_inc+1
Ang_inc=Angle/Nsteps
Delz=(Zend-Zstart)/Nsteps

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

FOR I=0 TO Nsteps
        Ang= Astart+I*Ang_inc
        X1=Xcen+Radius1*COS(Ang)
        Y1=Ycen+Radius1*SIN(Ang)
        Z1=Zstart+I*Delz
        X2=Xcen+Radius2*COS(Ang)
        Y2=Ycen+Radius2*SIN(Ang)
        Z2=Zstart+I*Delz

        Pt=PointXYZ(X1,Y1,Z1)
        Stat=AddToGroup(Group,Pt)
        Pt_count=Pt_count+1

        Pt=PointXYZ(X2,Y2,Z2)
        Stat=AddToGroup(Group,Pt)
        Pt_count=Pt_count+1
NEXT I

surf= GridSurface(WsCubicSurfEnt,Group,"HELICAL SURF",2,Nsteps+1)

ActivateUndo
Stat= AdvanceUndoNumber("helical surf")
Stat= AddItemToUndo(WsUBCreateMode,Surf)

stat= DeleteGroup(Group,1)

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

