Older Version Newer Version

cogburn cogburn May 25, 2012

Ballistic Trajectory Calculator

Input the initial velocity in m/s and the initial angle in degrees and this program will calculate and display trajectory parameters.

'Trajectory Calculator Ver. 1.0
'Scott Ausbrooks
'May, 2012
 
'This program calculates ballistic trajectories ignoring air resistance.
 nomainwin
 WindowWidth = 900
 WindowHeight = 500
 
 button #1.button1,"Calculate",[action], UL, 10,30,120,50
 button #1.button2,"Clear",[clear], LL, 10,20,120,50
 button #1.button3,"Exit",[quit],LR,120,60,120,50
 textbox #1.textbox0, 650, 30, 180, 60'velocity
 textbox #1.textbox2, 650, 230, 180, 60'angle
 textbox #1.textbox3, 160, 20, 360, 270'result
 statictext #1.velocity, "Initial Velocity",550,30,100,50
 statictext #1.theta, "Initial Angle",550,230,100,60
 statictext #1.result, "Result",300,300,150,25
 open "Trajectory Parameters" for window as #1
 print #1, "font times_new_roman 14 BOLD"
 print #1.textbox0, "!setfocus"
 print #1, "trapclose [quit]"
 wait
[action]
 print #1.textbox2,"!contents?"
 input #1.textbox2, Theta
 print #1.textbox0,"!contents?"
 input #1.textbox0, Vi
 
 g = 9.81
 Vy = Vi * sin (Theta/57.29578)
 roundedVy = int(Vy*10^2 +0.5) / 10^2
 Vx = Vi * cos (Theta/57.29578)
 roundedVx = int(Vx*10^2 +0.5) / 10^2
 deltaTmaxh = Vy/g
 roundeddeltaTmaxh = int(deltaTmaxh*10^2 +0.5) / 10^2
 DTtotal = 2*deltaTmaxh
 roundedDTtotal = int(DTtotal*10^2 +0.5) / 10^2
 Altitude = (Vy^2)/(2*g)
 roundedAltitude = int(Altitude*10^2 +0.5) / 10^2
 Range = DTtotal * Vx
 roundedRange = int(Range*10^2 +0.5) / 10^2
 
 print #1.textbox3, "Velocity in the y direction = " ; roundedVy;" m/s"+ chr$(13) + chr$(10) +"Velocity in the x direction = "; roundedVx; " m/s"+ chr$(13) + chr$(10) +"Time to reach max. altitude = " ;roundeddeltaTmaxh; " sec"+ chr$(13) + chr$(10) +"Total hang time = "; roundedDTtotal; " sec"+ chr$(13) + chr$(10) +"Maximum Altitude = "; roundedAltitude; " m"+ chr$(13) + chr$(10) +"Maximum Range = ";roundedRange; " m"
 
 wait
[clear]
 
 print #1.textbox0, ""
 print #1.textbox2, ""
 print #1.textbox3, ""
 print #1.textbox0, "!setfocus"
wait
 
[quit]
 confirm "Really quit?";answer$
 if answer$ = "no" then wait
 close #1:end