is a time-scale variable that is a square of TimeRate!
both rates to = 1 for simplest solution.
For Ss3 = 0 to Planets 'zero
is the sun's number.
TraVX = 0: TraVY = 0: TraVZ = 0 'planet
velocity Traversed XYZ
For Ss2 = 0 to Planets
If Ss3 = Ss2 Then GoTo 200 'no
gravity on planet itself.
Ss2 is the effective
planet, Ss3 is is the effected
PoY PoZ are real positions in km for XYZ axes.
'Preset the positions yourself prior to this routine.
Xx = PoX(Ss2) - PoX(Ss3)'Get
the distance between the bodies.
Yy = PoY(Ss2) - PoY(Ss3)
Zz = PoZ(Ss2) - PoZ(Ss3)
Dist = distance between bodies.
Dist = ((Xx * Xx) + (Yy * Yy)
+ (Zz * Zz)) ^ (0.5)
'Radbody = radius of body. Exclude
close encounters here:
If Dist > RadBody Then
Newton's equation * time-scale variable:
= ((Mass(Ss2)*Gee) / (Dist^2)) * GRate
= virtual gravity force.
Zp = Zz / Dist 'Zp
is Z-proportion from Zz distance, ditto Xx & Yy.
Yp = Yy / Dist
Xp = Xx / Dist
GravX = Gfor * Xp 'Gravity
GravY = Gfor * Yp
GravZ = Gfor * Zp
'GraVX GraVY GraVZ are
individual shifts in velocity caused by
'gravity-force for each isolated interaction in quantum
TraVX = TraVX + GraVX
TraVY = TraVY + GraVY
TraVZ = TraVZ + GraVZ
'TraVX TraVY TraVZ are accumulated
'for each planet in quantum time.
'TotalX TotalY TotalZ are combined
shifts in velocity.
'for a single step in time from all planets.
TotalX(Ss3) = TraVX
TotalZ(Ss3) = TraVZ
first pair of for...next loops are now complete.
'They have determined what the changes to the planetary velocities
'Now this is where the velocities are actually changed for each time
'MoX MoY MoZ are motion variables for all time, so do not set them
'Starting motion/velocities not here included, define those yourself
prior to this routine.
For Ss4 = 0 to Planets
MoX(Ss4) = MoX(Ss4) + TotalX(Ss4)
MoY(Ss4) = MoY(Ss4) + TotalY(Ss4)
MoZ(Ss4) = MoZ(Ss4) + TotalZ(Ss4)
velocity has changed, now we move the positions of each planet.
For Ss5 = 0 to Planets 'positions
moved by motion
PoX(Ss5) = PoX(Ss5) + MoX(Ss5)
PoY(Ss5) = PoY(Ss5) + MoY(Ss5)
PoZ(Ss5) = PoZ(Ss5) + MoZ(Ss5)
'now put the actual dots on the screen:
For Ss6 = 0 To Planets
'Zoom is distance scale,
'balX balY balZ balance position on screen. Figure these yourself.
PsX = (PoX(Ss6) / Zoom) + balX
PsY = (PoY(Ss6) / Zoom) + balY
'PsX PsY PsZ are screen positions in
balX, balY, balZ are your
screen position variables balanced to center-screen.
PSet (PsX, PsY), PlanetColor 'draw
pixel: top-view, main screen.
'zxaxisZ will also require your
zoom and balance adjustments
= (PoZ(Ss6) / Zoom) + balZ
are similar to PsX & PsY
ViewXZ.PSet (zxaxisX, zxaxisZ), PlanetColor
'draw side-view (XZ-axis).
(zyaxisZ, zyaxisY), PlanetColor 'draw
Goto 100 'not
required if using an event-timer that loops itself.