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

!A
!A NAME:
!A
!A 	Involute
!A
!A DESCRIPTION:
!A
!A 	This script constructs a spline curve through a involute.
!A
!B INSTRUCTIONS:
!B
!B 	RADIUS OF CIRCLE: Enter the radius of the base circle for the
!B 		involute.
!B
!C NOTE: 
!C	
!C	If a string wound around a fixed circle is unwound while held
!C	taut in the plane of the circle, its end traces out the
!C	involute of a circle.	
!C

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

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

ActivateUndo
Stat=SetInputFormat("n4","")

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

R1=InputRadius("RADIUS OF BASE CIRCLE ")
IF (ExitScript(Destination$)) THEN Leave

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



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

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

PlotOff
Stat= DeleteEntity(Center)
FOR I=0 TO Nsteps
	Ang= Astart+I*Ang_inc
	A1= Ang*PI/180.0
	X= Xcen+ R1*COS(Ang)+ R1*A1*SIN(Ang)
	Y= Ycen+ R1*SIN(Ang)- R1*A1*COS(Ang)
	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(Pt)
PlotOn
Stat=PlotEntity(Spline_group)
ActivateUndo
Stat= AdvanceUndoNumber("involute")
Stat= AddItemToUndo(WsUBCreateMode,Spline_group)
GOTO Group_loop


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

