home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. CD ROM (Annual Premium Edition)
/
premium.zip
/
premium
/
DOSGRAPH
/
ORBIT10.ZIP
/
ORBIT.RTA
< prev
next >
Wrap
Text File
|
1993-02-06
|
3KB
|
102 lines
// Orbital simulation.
// This is the control file for RTAG (Ray Tracing Animation Generator).
// Produced by Phillip H. Sherrod
// --- File declarations ---
bfile orbit // Batch file is ORBIT.BAT
// --- General simulation data ---
var numframes = 200
var endtime = 200
var timestep = .1
var sf = 5 // Speed/distance factor
// --- Planet orbital data ---
// Planet 1
var smaj1 = 6.443832 // Semi-major axis
var smin1 = 5.780208 // Semi-minor axis
var phase1 = 0 // Phase angle
// Planet 2
var smaj2 = 9.028421
var smin2 = 8.516810
var phase2 = 0
// Planet 3
var smaj3 = 12.960591
var smin3 = 11.520525
var phase3 = 0
// Moon around planet 3
var mr = 2 // Radius of moon's orbit
var phasem = 60 // Orbital position angle when time = 0.
var moonfreq = 5 // Number of times moon orbits
// --- Other variables ---
var x1,z1,f1,s1,d1
var x2,z2,f2,s2,d2
var x3,z3,f3,s3,d3
var xm,zm,sm
var time,frametime,framestep
// --- Initialization ---
// Compute position of foci (along x axis)
f1 = sqrt(smaj1^2 - smin1^2)
f2 = sqrt(smaj2^2 - smin2^2)
f3 = sqrt(smaj3^2 - smin3^2)
// Angular velocity of moon
sm = (360 * moonfreq) / endtime
// Compute time between frames
framestep = endtime / numframes
// --- Simulation procedure ---
for time = 0 while (time < endtime) step timestep do
// Compute current position
x1 = f1 + smaj1 * cos(phase1)
z1 = smin1 * sin(phase1)
x2 = f2 + smaj2 * cos(phase2)
z2 = smin2 * sin(phase2)
x3 = f3 + smaj3 * cos(phase3)
z3 = smin3 * sin(phase3)
xm = x3 + mr * cos(phasem)
zm = z3 + mr * sin(phasem)
// See if it is time to output a frame
if (time >= frametime) then
nextframe
// Display our positions
print "frame %3.0lf, time %5.1lf (%7.3lf,%7.3lf) (%7.3lf,%7.3lf) (%7.3lf,%7.3lf)",\\
curframe,time,x1,z1,x2,z2,x2,z3
// Generate batch file commands to declare position for frame.
bwrite "echo #declare x1 = `x1` > orbit.inc"
bwrite "echo #declare z1 = `z1` >> orbit.inc"
bwrite "echo #declare x2 = `x2` >> orbit.inc"
bwrite "echo #declare z2 = `z2` >> orbit.inc"
bwrite "echo #declare x3 = `x3` >> orbit.inc"
bwrite "echo #declare z3 = `z3` >> orbit.inc"
bwrite "echo #declare xm = `xm` >> orbit.inc"
bwrite "echo #declare zm = `zm` >> orbit.inc"
// Generate batch file command to render this frame.
bwrite "call render orbit orbit`###`"
// Remember when to generate next frame
frametime = frametime + framestep
endif
// Compute distance from focus (the focus is at 0,0)
d1 = sqrt(x1*x1 + z1*z1)
d2 = sqrt(x2*x2 + z2*z2)
d3 = sqrt(x3*x3 + z3*z3)
// Compute linear speed based on distance from focus (Kepler's law)
s1 = atan(1 / d1)
s2 = atan(1 / d2)
s3 = atan(1 / d3)
// Since we are generating the ellipse from the center rather
// than the focus, we must compute the angular speed necessary
// to produce the desired linear speed.
d1 = sqrt((x1-f1)^2 + z1*z1)
d2 = sqrt((x2-f2)^2 + z2*z2)
d3 = sqrt((x3-f3)^2 + z3*z3)
s1 = (sf * s1) / d1
s2 = (sf * s2) / d2
s3 = (sf * s3) / d3
// Advance angles
phase1 = mod(phase1 + timestep * s1, 360)
phase2 = mod(phase2 + timestep * s2, 360)
phase3 = mod(phase3 + timestep * s3, 360)
phasem = mod(phasem + timestep * sm, 360)
endfor
// Put last command in batch file.
epilog
bwrite "call dodta ORBIT /S7"