
! script name: nurbs.d/bspline
! topic: construct bspline between two points

!A
!A NAME:
!A
!A 	Bspline
!A
!A DESCRIPTION:
!A
!A 	This script constructs a bspline between two points.  The bspline
!A 	is a rational function of fixed degree and it offers the option of
!A 	non-uniform parameterization.
!A
!B INSTRUCTIONS:
!B
!B 	STARTING ABS X,Y,Z: Enter the X,Y,Z coordinates of the start
!B 		point for the bspline.  NOTE: See XYZ INPUT OPTIONS.
!B
!B 	ENDING ABS X,Y,Z: Enter the X,Y,Z coordinates of the end point
!B 		for the bspline.
!B
!B 	STARTING ANGLE: Enter the angle the bspline should pass through the
!B 		starting point.
!B
!B 	STARTING WEIGHT: Enter the starting weight which determines how far
!B 		away the tangent starts influencing the curve for the 
!B 		starting point.
!B
!B 	ENDING ANGLE: Enter the angle the bspline should pass through the
!B 		ending point.
!B
!B 	ENDING WEIGHT: Enter the ending weight which determines how far away
!B 		the tangent starts influencing the curve for the ending point.
!B
!# see also - points.d/xyzinput.hlp

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

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

Stat=SetInputFormat("n4a1=",",I,A,")

ActivateUndo
Spline_loop:!
Stat=SetPickReturn(WsGeometryEnd)
Ps=XyzInput("STARTING",WsXyzInput)
IF (ExitScript(Destination$)) THEN Leave

Stat=SetLastPoint(Ps)
Pe=XyzInput("ENDING",WsXyzInput)
IF (ExitScript(Destination$)) THEN Leave

Stat=SetPickReturn(WsLineAngle)
Angle1=GetValue("STARTING ANGLE",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Wt1=GetValue("STARTING WEIGHT",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Stat=SetPickReturn(WsLineAngle)
Angle2=GetValue("ENDING ANGLE",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Wt2=GetValue("ENDING WEIGHT",Answer$)
IF (ExitScript(Destination$)) THEN Leave

S1=BSplineTwoPts(Ps,Angle1,Wt1,Pe,Angle2,Wt2)

Stat=SetLastPoint(Pe)
Stat=DeleteEntity(Ps)
Stat=DeleteEntity(Pe)

ActivateUndo
Stat= AdvanceUndoNumber("nurb curve")
Stat= AddItemToUndo(WsUBCreateMode,S1)
GOTO Spline_loop

Leave:!

Stat=DeleteEntity(Ps)
Stat=DeleteEntity(Pe)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
