It's a field of study called exterior ballistics, and the work usually involves the numerical solution of complicated differential equations of motion.
In WWI when the Germans were firing their Paris gun, they had to account for, among other variables, changes in gravity, density of the atmosphere, curvature of the earth, coriolis forces, the gravitational effect of the moon, the temperature, and the condition of the propellant.
