
! script name: solids.d/sphere
! 3dtopic: construct sphere

!A
!A NAME:
!A
!A 	Sphere: Define
!A
!A DESCRIPTION:
!A
!A 	This script constructs a sphere or a part of a sphere.  A sphere
!A 	is the set of all points in 3d space equidistant from a fixed point.
!A
!B INSTRUCTIONS:
!B
!B 	RADIUS: Enter the radius, the measure of the constant distance from
!B 		the center of the sphere.
!B
!B 	STARTING LENGTH: Enter the controlling extent of the sphere along the
!B 		axis, negative measures backward from the starting point, zero
!B 		is the center or starting point.
!B
!B 	ENDING LENGTH: Enter the controlling extent of the sphere along the
!B 		axis, positive measures forward from the starting point, zero
!B 		is the center or starting point.
!B
!B 		NOTE: The starting length and ending length should not exceed
!B 		the radius of the sphere.  The default value indicates the
!B 		limits.
!B
!B 	STARTING ANGLE: Enter the starting angle of the sphere.  The starting
!B 		angle along with the angular extent are the controlling factor
!B 		for the sphere around the axis.
!B
!B 	ANGULAR EXTENT: Enter the number of degrees and the direction
!B 		( + CCW, - CW ) from the starting angle to the ending angle.
!B 		The angular extent determines the ending angle.
!B
!B 	CENTER POINT ABS X,Y,Z: Enter the X,Y,Z coordinates of the center
!B 		point, or fixed point, of the sphere.  
!B 		NOTE: See XYZ INPUT OPTIONS.
!B
!B 	ROTATION ANGLE: Enter the orientation angle of the axis of the sphere
!B 		in the XY plane.
!B
!B 	AXIS TILT ANGLE: This represents the angle of tilt of the axis line
!B 		of the sphere with respect to the XY plane.
!B
!B 	AXIS ROLL ANGLE: This represents the roll angle around the axis line
!B 		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 ")

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

ActivateUndo
Units= CurrentUnits
IF Units= WsMetric THEN
        Radius= 25
        Length= 100
ELSE
        Radius= 1
        Length=5
END IF
Astart= 0
Angle= 180
Cloop:!

Stat=SetInputFormat("n4=","")
Stat=SetRadiusEquals(Radius)
Radius=InputRadius("RADIUS")
IF ExitScript(Destination$) THEN Leave

Stat=SetInputFormat("n4=","")
Stat=SetEqualsValue(-Radius)
Start_length=GetValue("STARTING LENGTH",Answer$)
IF ExitScript(Destination$) THEN Leave

Stat=SetInputFormat("n4=","")
Stat=SetEqualsValue(Radius)
End_length=GetValue("ENDING LENGTH",Answer$)
IF ExitScript(Destination$) THEN Leave

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

Stat=SetInputFormat("n4=","")
Stat=SetEqualsValue(Angle)
Angle=GetValue("ANGULAR EXTENT",Answer$)
IF ExitScript(Destination$) THEN Leave

Stat=SetInputFormat("n4","")
Pt=XyzInput("CENTER POINT ",WsXyzInput)
IF ExitScript(Destination$) THEN Leave

Stat=SetAngleEquals(0)
Zangle=InputAngle("ROTATION ANGLE ",WsSigned)
IF ExitScript(Destination$) THEN Leave

Zangle=Zangle-90

Stat=SetAngleEquals(0)
Xangle=InputAngle("AXIS TILT ANGLE ",WsSigned)
IF ExitScript(Destination$) THEN Leave

Stat=SetAngleEquals(0)
Yangle=InputAngle("AXIS ROLL ANGLE ",WsSigned)
IF ExitScript(Destination$) THEN Leave

T1=AngleTransform(Pt,Xangle,Yangle,Zangle,WsWorkplaneVals)

C1=Sphere(T1,Radius,Start_length,End_length,Astart,Angle)
Stat=DeleteEntity(Pt)

ActivateUndo
Stat= AdvanceUndoNumber("sphere")
Stat= AddItemToUndo(WsUBCreateMode,C1)
GOTO Cloop

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