Haha,
I wish I had read your post before I went ahead with second test for MK19 G_40mm_HE!
Four shots at four different altitudes:
K = (4.98 +/- 0.08)*10^-4
g = 9.81 +/- 0.02
First velocity measured = 238.71 +/- 0.28
Not bad, eh? Now if you could dig through the weapon configs and get the muzzle velocities we would be set. I can also improve my function to take terrain slope into account.
edit:
If the value of 'a' is the total acceleration of the round with air friction, would that be equal to the muzzle velocity (v) that we plug into our old friend, the algorithm for angle of launch ((asin (gd / v^2)) * 0.5)? That would be excellent if it were. I'd highly prefer allowing ArmA's physics engine to handle the flight of the artillery shell over any other "creative" solution.
Um, why not use the code I provided? What you want to do is add and action to the cannon that calls a script. The script exits if it is not the gunner. The script calls my code. You can then display the range of the shot, and the height difference.
If you want to solve for what elevation to hit a given target, forget about it. I mean, it can be done, but it is non-trivial, at least to people without 2 years of undergraduate math or physics. There is also the problem that if your artillery has a large range of elevation and your target is in a certain range there are two solutions, a high angle and a low angle. A numerical solution is guaranteed, but not for the angle you may want. You would want the low angle for flat terrain becuase it hits the target sooner. You would want the high angle if there was terrain in the way.
Here is how it could be done. I don't think the ArmA engine could handle it without a few hiccups.
1) Use parabola to estimate the elevation required to hit the target. It there are two viable elevations keep them both.
2) For each parabola estiamte: plug the elevation into my code and get the impact point. Calculate whether shot went too far or too close. Adjust elevation. Try again. Repeat until within a given tolerance of target.
This is literally called "the shooting method"
http://www.physics.louisville.edu/help/nr/bookfpdf/f17-1.pdf and uses an algorithm to decide what the next guesses for elevation should be.
A better solution is to fit a polynomial to the trajectory based on the elevation.