Simulating Simple Ballistic Motion on the Apple ][

The very first flights of the American space program were the Mercury-Redstone Ballistic flights.  A total of six Mercury-Redstone vehicles were launched between November 21, 1960 and July 21, 1961 on sub-orbital ballistic trajectories that carried the Mercury Spacecraft from Cape Canaveral Air Force Station to splashdown in the North Atlantic.  Two of these missions were crewed by humans — MR3 on May 5, 1961 carried America’s first Astronaut Alan B. Shepard into space in his capsule Freedom 7; and MR4 on July 21, 1961 piloted by Astronaut Gus Grissom in his capsule Liberty Bell 7.

LIFTOFF OF MR-3 (MERCURY-REDSTONE 3) FREEDOM ¦, MANNED SUBORBITAL FLIGHT. ASTRONAUT SHEPARD, ALAN, FIRST MAN IN SPACE. MAY 5, 1961 REF: LOD 61C-884 (MIX FILE)
LIFTOFF OF MR-3

Unlike later Mercury missions, these Mercury-Redstone flights did not go into orbit around the Earth; rather they “went up like a cannon ball and came down like a cannonball.”  From an engineering perspective, these flights were important because they facilitated the development of an attitude control system that could orient the spacecraft in a given direction, life-support systems that could keep an astronaut alive in the vacuum of space, heat-shields that could protect a spacecraft and its occupants during re-entry, communications, and tracking systems.

From the standpoint of simulating the basic physics of spaceflight, these missions are an ideal starting point — we can disregard the complexity of orbital mechanics and concentrate on the relatively simple physics of ballistic motion.  This first attempt at creating an Applesoft Program to simulate ballistic motion is pretty bare-bones:  it doesn’t take air resistance into account, nor does it attempt to simulate the attitude of the spacecraft or any of the systems therein.  For all intents and purposes, we are simply simulating ballistic motion, be it a baseball, a cannon shell, or a spaceship.

100 TEXT : HOME : SPEED= 255
110 HGR : HCOLOR= 3
120 VTAB 21: ONERR GOTO 5000
130 LET HS = 2.74400055E - 03
140 LET VS = 6.26803705E - 03
150 GOSUB 4000
160 PRINT "SIMPLE BALLISTIC MOTION FOR THE APPLE ]["
170 PRINT 
180 INPUT "INITIAL VELOCITY: ";V0
190 IF V0 < > 0 THEN 210
200 NORMAL : TEXT : HOME : END 
210 IF V0 < 1000 THEN 240
220 PRINT "EXCESS VELOCITY. TRY AGAIN!"
230 GOTO 180
240 INPUT "LAUNCH ANGLE: ";TD
250 GOSUB 1000: REM CALCULATE FLIGHT DATA
260 GOSUB 3000: REM PLOT FLIGHT DATA
270 GOSUB 2000: REM DISPLAY FLIGHT DATA
280 GET A$: IF A$ = "" THEN 280
290 GOTO 170
1000 REM CALCULATE FLIGHT DATA
1010 LET G = 9.8
1020 LET PI = 22 / 7
1030 LET T = TD * (PI / 180)
1040 LET VX = V0 * COS (T)
1050 LET VY = V0 * SIN (T)
1060 LET H = (VY ^ 2) / (2 * G)
1070 LET TP = VY / G
1080 LET TT = TP * 2
1090 LET R = ((V0 ^ 2) * SIN (T * 2)) / G
1100 RETURN 
2000 REM DISPLAY FLIGHT DATA
2010 HOME : VTAB 21: HTAB 1: INVERSE 
2020 PRINT "ANGLE: ";
2030 VTAB 21: HTAB 21
2040 PRINT "VELOCITY: ";
2050 VTAB 22: HTAB 1
2060 PRINT "HEIGHT: ";
2070 VTAB 22: HTAB 21
2080 PRINT "RANGE: ";
2090 VTAB 23: HTAB 1
2100 PRINT "P TIME: ";
2110 VTAB 23: HTAB 21
2120 PRINT "T TIME: ";
2130 NORMAL : VTAB 21: HTAB 12
2140 PRINT INT (TD);
2150 VTAB 21: HTAB 32
2160 PRINT INT (V0);
2170 VTAB 22: HTAB 12
2180 PRINT INT (H);
2190 VTAB 22: HTAB 32
2200 PRINT INT (R);
2210 VTAB 23: HTAB 12
2220 PRINT INT (TP);
2230 VTAB 23: HTAB 32
2240 PRINT INT (TT);
2250 RETURN 
3000 REM PLOT TRAJECTORY IN HIGH RES
3010 REM 
3020 FOR ET = 0 TO INT (TT) STEP 0.5
3030 LET X = VX * ET * HS
3040 LET Y = VY * ET - (0.5 * G * ET ^ 2)
3050 LET Y = Y * VS
3060 HPLOT X,160 - Y
3070 NEXT ET
3080 LET PX = VX * TP * HS
3090 LET PY = (VY * TP - (0.5 * G * TP ^ 2)) * VS
3100 HPLOT INT (PX), INT (160 - PY) TO INT (PX),159
3110 RETURN 
4000 REM PLOT SCALE ON MONITOR
4010 HPLOT 0,0 TO 0,159
4020 HPLOT 0,159 TO 279,159
4030 FOR I = 0 TO 159 STEP INT (159 / 25)
4040 HPLOT 0,160 - I TO 5,160 - I
4050 NEXT I
4060 FOR I = 0 TO 279 STEP INT (280 / 100)
4070 HPLOT I,159 TO I,154
4080 NEXT I
4090 RETURN 
5000 REM ERROR HANDLING ROUTINE
5010 PRINT CHR$ (7);"RANGE ERROR -- VALUE EXCEEDS PLOT RESOLUTION."
5020 END

When the program begins, it draws a reticle on the screen used to scale the display.  In the vertical direction, output is scaled to approximately 26 kilometers and in the horizontal direction, output is scaled to approximately 101 kilometers.  Although this is not enough resolution to simulate the flight of the Mercury spacecraft, it is intended as a proof of concept for work that will follow.  In this case, the degree of scaling was chosen in order to simulate the flight of an object launched at up to 999 meters per second at a launch angle of 45 degrees.

After preparing the display, the program prompts the user to enter the initial velocity and the launch angle.  It then calculates the flight parameters, attempts to plot them on the screen, and displays the final parameters of the flight at the bottom of the screen.  The program then waits for a keystroke and returns to the initial prompt for velocity.  The user can then either enter a zero to terminate the program, or enter another set of launch parameters.  The display is NOT cleared for subsequent plots, the previous flight path remains on the display. This is intended to allow for comparison of multiple runs.  The sample shown below demonstrates three individual runs — each run used a velocity of 999 meters per second at a selection of launch angles at 15 degrees, 30 degrees, and 45 degrees from the horizontal.

ballistic_plot

As you can see, the program calculates that an object launched at a 45 degree angle and a velocity of 999 meters per second will reach a maximum height of 25,475 meters in 72 seconds and will travel downrange a distance of 101,836 meters in 144 seconds total elapsed time. These figures are approximate and in general agreement with the values found by various online ballistic calculators.

One online resource that was used to confirm these calculations is:  http://hyperphysics.phy-astr.gsu.edu/hbase/traj.html

There are several obvious objections that come to mind when considering how closely this sort of simulation corresponds to the behavior of actual spacecraft.  First, a rocket begins with a velocity of zero and actually accelerates as it is boosted upwards. True ballistic motion does not begin until acceleration ceases.  Secondly, large rockets (and spacecraft) are launched vertically at an angle of 90 degrees to the horizontal and then maneuver in order to obtain the desired trajectory.  Finally, this simulation is strictly two-dimensional whereas real rockets and spacecraft travel through three dimensions and have to deal with things like atmospheric resistance, lift, drag, and variable gravitational fields.  These are subjects for future experimentation.