In practical terms, I'm looking to simulate the flight of an arrow from one location (the location of the bow) to another. I have already simulated the effects of gravity on my projectile by updating its velocity at each logic interval. What I'm now looking to figure out is exactly how I figure out the correct trajectory/angle to fire my arrow at in order to reach my target in the shortest time possible.
Any help would be greatly appreciated.
Pointy's answer is a good summary of how to simulate the movement of an object given an initial trajectory (where a trajectory is considered to be a direction, and a speed, or in combination a vector).
However you've said in the question (if I've read you correctly) that you want to determine the initial trajectory knowing only the point of origin
O and the intended point of target
The bad news is that in practise for any particular
P there's an infinite number of parabolic trajectories that will get you there from
O. The angle and speed are interdependent.
If we translate everything so that O is at the origin (i.e. [0, 0]) then:
T_x = P_x - O_x // the X distance to travel T_y = P_y - O_y // the Y distance to travel s_x = speed * cos(angle) // the X speed s_y = speed * sin(angle) // the Y speed
Then the position
(x, y) at any point in time
x = s_x * t y = s_y * t - 0.5 * g * (t ^ 2)
so at impact you've got
T_x = s_x * t T_y = -0.5 * g * (t ^ 2) + s_y * t
but you have three unknowns (
s_y) and two simultaneous equations. If you fix one of those, that should be sufficient to solve the equations.
s_y is equivalent to fixing either
angle, that bit is just simple trigonometry.
Some combinations are of course impossible - if the speed is too low or the angle too high the projectile will hit the ground before reaching the target.
NB: this assumes that position is evaluated continuously. It doesn't quite match what happens when time passes in discrete increments, per Pointy's answer and your own description of how you're simulating motion. If you recalculate the position sufficiently frequently (i.e. 10s of times per second) it should be sufficiently accurate, though.
I'm not a physicist so all I can do is tell you an approach based on really simple process.
Now a nuance you'll need to work out is the sign of "vy". The initial sign of "vy" should be the opposite of "delta vy". Which should be positive and which should be negative depends on how the coordinate grid relates to the screen.
edit — See @Alnitak's answer for something actually germane to your question.