
! script name: solids.d/sphere2pts
! 3dtopic: construct sphere defined by two unique points

!A
!A NAME:
!A
!A 	Sphere: Two Points
!A
!A DESCRIPTION:
!A
!A 	This script allows a sphere to be defined by two unique points.
!A
!B INSTRUCTIONS:
!B
!B 	CENTER POINT ABS X,Y,Z: Enter the X,Y,Z coordinates for the center
!B 		point.  NOTE: See XYZ INPUT OPTIONS.
!B
!B 	SECOND POINT ABS X,Y,Z: Enter the X,Y,Z coordinates for the second
!B 		point.  The distance between the CENTER POINT and the SECOND
!B 		POINT will determine the radius of the sphere.
!B
!C NOTES:
!C
!C 	The U contours of a sphere are the circles from the starting length
!C 	to the ending length.  The V contours of a sphere are the circles 
!C 	formed from the starting angle to the ending angle.
!C
!# see also - points.d/xyzinput.hlp

Stat=ChangeLabelStr("ScriptNameStatus","Function: sphere defined by 2 points ")

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

ActivateUndo
Sphere_loop:!

Stat=SetInputFormat("n4","")

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

P2=XyzInput("SECOND POINT",WsXyzInput)
IF ExitScript(Destination$) THEN Leave

Radius=DistTwoPts(Pc,P2)

Trans1=AngleTransform(Pc,0,0,0)
Sphere1=Sphere(Trans1,Radius)

Stat=DeleteEntity(Pc)
Stat=DeleteEntity(P2)

ActivateUndo
Stat= AdvanceUndoNumber("sphere")
Stat= AddItemToUndo(WsUBCreateMode,Sphere1)
GOTO Sphere_loop

Leave:!
Stat=DeleteEntity(Pc)
Stat=DeleteEntity(P2)
IF NOT LEN(Destination$) THEN
	LOAD "typecontrol"
ELSE
	LOAD Destination$
END IF
END
