This isn’t specific to lua, but I thought this would be a decent place to ask it;

I happen to know that theta=0.5*asin((g*d)/v^2)).

theta=Angle of launch

g=Gravitational constant

d=horizontal distance to target

v=Initial velocity

(asin is inverse sine)

I now need to be able to calculate the required launch angle to send a projectile at given velocity to impact a target at horizontal distance d from the starting point of the projectile, as well as vertical distance Dy from the starting position.

The current formula works well when the target is at the same elevation as the point of origin. I need to somehow factor in Dy (vertical distance) to give me a new angle, to be able to strike targets that are at different elevations.

I hope I’ve been clear enough; Can anyone help?