Ballistic Launch Calculator
- 1 Devlogs
- 3 Total hours
Calculates, to a reasonable degree of precision, a launch angle to hit a given target based on it’s distance and a few bits of info about the launcher
Calculates, to a reasonable degree of precision, a launch angle to hit a given target based on it’s distance and a few bits of info about the launcher
Created a proof of concept This is very ugly, and just to prove that my algorithm will work in Javascript. This will also provide a “backbone” that will be torn down and rebuilt. It i just some prompt boxes and two ugly lines of formulas, but here is the code: function degrees(radians) { return radians * (180 / Math.PI); } var v = Number(prompt("Enter initial velocity (m/s):")); var d = Number(prompt("Enter distance (m):")); var h = Number(prompt("Enter height (m):")); var g = Number(prompt("Enter absolute acceleration due to gravity (m/s^2):")); var thetaHR = Math.atan((d*v**2+v**2*Math.sqrt(d**2-4*((g*d**2)/(2*v**2))*((g*d**2)/(2*v**2)+h)))/(g*d**2)); var thetaLR = Math.atan((d*v**2-v**2*Math.sqrt(d**2-4*((g*d**2)/(2*v**2))*((g*d**2)/(2*v**2)+h)))/(g*d**2)); var thetaH = degrees(thetaHR); var thetaL = degrees(thetaLR); alert("High angle: " + thetaH + " degrees\nLow angle: " + thetaL + " degrees");