I am trying to determine the gun elevation angle of a gun that fires ballistic projectiles.
For a target at a certain distance D, I will have to compute an angle that increases with D.
This relation ship is non-linear, by the way, because the projectile loses velocity as it travels, for starters, due to drag.
In the past, I have done this with a lookup table.... for a whole bunch of test firings, see where the projectile hits the ground.
But this only works if there is no delta in the elevation between gun and target.
A target that is on a hill top, will need adjustment for extra range. Whereas a target in a valley below, would mean a lower gun elevation.
This means that the table-lookup will break down, and a 2D table seems like a kludge.
What would be an effective way to compute this targeting? I know things also depend on nozzle-velocity and air-drag, but these will not vary (but drag will be non-zero.) Neither will I be modeling the wind.
This is for AI assisted targeting. NPC or player targets a point in the world. The algorithm will find the corresponding angle to hit the target.
Currently, I am using Bullet Physics, with a discretely stepped world.