For a little background, this problem came up due to something I'm trying to code, however the problem itself is disparate from that. I know the basics of projectile motion and kinematics from a pair of Physics classes I took for CCP, but to figure this out would be far too tedious at current.

Is it possible to figure out the angle of a projectile's lauch knowing only x naught, y naught, x one, y one, "gravity," and the magnitude of the initial velocity? No time, no components of the velocity, and no final velocity.

Intuitively I can tell you that there should be exactly two answers for any given starting conditions (with the exception of anything where (x1, y1) lies at the vertex of any trajectory above 45°, if my sleepy brain processes that right), and I want both of those. The thing is that I don't know of any equations that can pull that angle out (even just vx0 or vy0 would be enough) without time, which is something I explicitly want to be able to pull from this equation for the next iteration.

For reference, the reason I need to do it this way if because I'm internationally refining a predicted trajectory based on another moving object (therefore time is needed to figure how far said other object will move in that time), as shown here, in the non-gravity-compensating version: https://paste.mod.gg/ejoxasabod.cpp Since the code is recursive, I need an equation that plays nicely with that, and doesn't need time up front. Unless - and I know this is veering off math and into code - there is a way to use straight-line-time to estimate the time needed. That is, is it possible to turn this into a problem of ratios? If I know the magnitude of the initial velocity and the positions of both objects, is it feasible to figure out time just by inferring how long it would have to take based on how far off of horizontal the final location is?

I know for a fact that this is possible, but I'm not sure how to do it at the moment. I'm certain a system of equations could do it, but I'm not sure if I could code that in in C#. If anyone has any ideas on either the math or coding aspects, throw them my way; they are greatly appreciated!

  • $\begingroup$ How are $(x_0, y_0)$ and $(x_1, y_1)$ related to the projectile? Are they any two different positions along the path of motion? $\endgroup$
    – John Douma
    Jun 20, 2021 at 7:02
  • $\begingroup$ Interpolation of quadratic functions might help here. $\endgroup$ Jun 20, 2021 at 8:00

1 Answer 1


Supposing that the initial coordinates are $(x_i,y_i)$, the projectile equations are

$$ \cases{ x= x_i+(v_0\cos\theta) t\\ y=y_i +(v_0\sin\theta)t-\frac 12 gt^2 } $$

eliminating the time

$$ 2v_0^2\cos\theta((y-y_i)\cos\theta-(x-x_i)\sin\theta)+g(x-x_i) = 0 $$

so we have two equations

$$ \cases{ 2v_0^2\cos\theta((y_0-y_i)\cos\theta-(x_0-x_i)\sin\theta)+g(x_0-x_i) = 0\\ 2v_0^2\cos\theta((y_1-y_i)\cos\theta-(x_1-x_i)\sin\theta)+g(x_1-x_i) = 0 } $$

and three unknowns $x_i,y_i,\theta$. Solving for $y_i,\theta$ after assuming $x_i=0$ we will find theoretically $8$ solutions...


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .