05-13-2025, 06:19 PM
I got most of this math from a BASIC Programming FB group I belong to and some from ChatGPT.... because I'm horrible at math. lol
Select the X,Y,Z size of your globe and the speed then watch it spin. Press Space Bar to make another one or Esc to quit.
This could be used in some kind of space game or model.
Select the X,Y,Z size of your globe and the speed then watch it spin. Press Space Bar to make another one or Esc to quit.
This could be used in some kind of space game or model.
Code: (Select All)
_Title "Globe Spin - Space Bar For Another One - Esc To End"
Screen _NewImage(800, 600, 32)
Do
start:
Cls
Input "XRADIUS (10-500)="; XRADIUS
If XRADIUS < 10 Or XRADIUS > 500 Then GoTo start
Input "YRADIUS (10-500)="; YRADIUS
If YRADIUS < 10 Or YRADIUS > 500 Then GoTo start
Input "ZRADIUS (10-500)="; ZRADIUS
If ZRADIUS < 10 Or ZRADIUS > 500 Then GoTo start
Input "SPEED (-20 to 20)"; speed
If speed < -20 Or speed > 20 Then GoTo start
II = 0
speed2 = speed / 100
Do
For I = 0 To _Pi Step .2 ' Latitude angle (from pole to pole)
For K = II To 2 * _Pi + II Step .2 ' Longitude angle (rotation)
X = XRADIUS * Sin(I) * Cos(K)
Y = YRADIUS * Cos(I)
Z = ZRADIUS * Sin(I) * Sin(K)
XPLOT = X + Z / 5 + 400
YPLOT = Y + Z / 5 + 300
Line -(XPLOT, YPLOT)
Next K
Next I
' Draw longitudinal lines (pole to pole)
For LON = 0 To 2 * _Pi Step .4
For LAT = 0 To _Pi Step .2
X = XRADIUS * Sin(LAT) * Cos(LON + II)
Y = YRADIUS * Cos(LAT)
Z = ZRADIUS * Sin(LAT) * Sin(LON + II)
XPLOT = X + Z / 5 + 400
YPLOT = Y + Z / 5 + 300
Line -(XPLOT, YPLOT)
Next LAT
Next LON
II = II + speed2
Locate 1, 1: Print "XRADIUS: "; XRADIUS
Locate 2, 1: Print "YRADIUS: "; YRADIUS
Locate 3, 1: Print "ZRADIUS: "; ZRADIUS
Locate 4, 1: Print "SPEED: "; speed
_Delay .1
If a$ = Chr$(27) Then End
_Display
Cls
a$ = InKey$
Loop Until a$ = " "
Loop

