Take the 2-minute tour ×

I am trying to find the angle needed for a projectile to pass-through a given point.

Here is what I do know:

  • Starting Point $(x_0,y_0)$
  • Velocity
  • Pass-through point $(x_1, y_1)$

I also need to incorporate gravity into the equation. Anyone have any ideas? I haven't had much luck so far, so any ideas/suggestions would be great.

share|improve this question

closed as off-topic by Emilio Pisanty, tpg2114, Qmechanic Nov 6 '13 at 22:17



5 Answers 5

The answer posted eight hours ago is not correct. The formula given by Akash works for two points on the same level, and the question has the trajectory passing through two arbitrary points.

More importantly, the answer suggests that the right way to do trajectory problems is by knowing the right formulas. Trajectories are fun and you can learn a lot of physics by figuring them out in any number of ways. You don't learn anything if you do them by plugging numbers into formulas.

Having said that, this appears to be one of the more difficult types of trajectory problems. I have three equations in three unknows...v_x, v_y, and T. Eliminating v_x and v_y I get a quadratic equation in T^2. This is correct because there are two solutions for the problem...one where you aim the projectile as close as possible to the target, and the other where you loft it high in the air and hit the target on the way down.

share|improve this answer
Ok, i think i understand what you are saying. Basically i am trying to pass through the point by aiming the projectile as close as possible. I am unsure where to even begin to find this angle. The closest i could find was on this page en.wikipedia.org/wiki/Trajectory_of_a_projectile in the section titled Angle required to hit coordinate, but i can't get that equation to work at all. –  NineBlindEyes Mar 8 '13 at 20:42
@NineBlindEyes: Try the equation I give. Unless I've made a mistake, it should give the two possible answers. –  Phil H Mar 11 '13 at 13:31
I believe that this should rather be a comment but not an answer. –  Peter Kravchuk May 10 '13 at 17:19
Ahh, I've just noticed that it all was in March, not in May) –  Peter Kravchuk May 10 '13 at 17:23

Assuming gravity acting downwards, we can separate the horizontal and vertical motion; horizontally, it moves at a constant speed. Vertically, it is accelerating at $-g$.

Since we have the initial speed $s$, we know that for some angle $\theta$ between the $x$-axis and the initial velocity, the horizontal component of that velocity will be $v \cos(\theta)$. So the time of flight will be:

$\tau = (x_1 - x_0) / (v \cos(\theta) )$

We also know that vertically the projectile is accelerated by gravity, giving us a quadratic equation for the motion, so it will pass the elevation both on the way up and the way down (unless it coincides with the peak). This time the component of the velocity is $v \sin(\theta)$, so using $s = s_0 + ut + \frac{1}{2}a t^2$

$y_1 = y_0 + v \sin(\theta) \tau + \frac{1}{2}(-g)\tau^2$

We want $\theta$ in terms of everything else, and $\tau$ is unknown. So we want to substitute the first equation into the second. But let's reduce the number of terms for now by looking at deltas: $\alpha = x_1 - x_0$, $\beta = y_1 - y_0$ (i.e. change origin):

$\tau = \alpha / (v \cos(\theta) )$

$\beta = v \sin(\theta) \tau - \frac{1}{2}g \tau^2$

Substitute for $\tau$:

$\beta = v \sin(\theta) \alpha / (v \cos(\theta) ) - \frac{1}{2}g \alpha^2 / (v^2 \cos^2(\theta) )$

$\beta = \sin(\theta) \alpha / \cos(\theta) - \frac{1}{2}g \alpha^2 / (v^2 \cos^2(\theta) )$

$\beta v^2 \cos^2(\theta) = v^2 \cos(\theta) \sin(\theta) \alpha - \frac{1}{2}g \alpha^2 $

Well, that looks fun. Untangling trig is not my preferred way to spend the afternoon. Let's play SOH CAH TOA. Imagine a right-angled triangle with angle $\theta$, base (adjacent) $\alpha$ (to pick a known quantity) and height (opposite) $\gamma$ (our new unknown). Hypotenuse $h$ then satisfies $h^2 = \alpha^2 + \gamma^2$. We get:

$\sin(\theta) = \gamma / h$

$\cos(\theta) = \alpha / h$

$\cos^2(\theta) = \alpha^2 / h^2$

$\cos(\theta) sin(\theta) = \alpha \gamma / h^2$


$\beta v^2 \alpha^2 / h^2 = v^2 \alpha^2 \gamma / h^2 - \frac{1}{2}g \alpha^2$

$\beta v^2 = v^2 \gamma - \frac{1}{2} g h^2 \quad$ (don't worry, the $\alpha$ dependence is still there in $h$)

Substitute for $h^2$ now that it is only there once:

$\beta v^2 = v^2 \gamma - \frac{1}{2} g (\alpha^2 + \gamma^2)$

Get in terms of $\gamma$, as that is our link to $\theta$:

$(\frac{1}{2} g) \gamma^2 - v^2 \gamma + \frac{1}{2} g \alpha^2 + \beta v^2 = 0$

$\gamma^2 - (2 v^2 / g) \gamma + (\alpha^2 + 2 \beta v^2 / g) = 0$

One quadratic equation (eventually). Calling the common factor $f = 2 v^2 / g$, we get:

$\gamma^2 - f \gamma + (\alpha^2 + \beta f) = 0$

In the best tradition:

$\gamma = \frac{1}{2}(f \pm \sqrt{f(f - 2\beta) - 2(\alpha^2) })$

From $\gamma$, we will want $\theta$, so to avoid square terms go for $\tan$:

$\tan(\theta) = \gamma / \alpha \quad$ (SOH CAH TOA)

$f$ can be calculated separately, so in code I would do this (pseudocode):

g = 9.81; // ish
alpha = x_one - x_zero;
beta = y_one - y_zero;
eff = 2 * v * v / g;
rootterm = eff*(eff - 2*beta) - 2*alpha*alpha;
// test for imaginary roots
if(rootterm < 0) {
    ... cannot hit target with this velocity ...
} else {
    gamma_first = (f + sqrt(rootterm))/2;
    gamma_second = (f - sqrt(rootterm))/2;
    theta_first = arctan(gamma_first / alpha);
    theta_second = arctan(gamma_second / alpha);

You are then free to choose which solution you prefer. In the case that $f(f - 2\beta) = 2 \alpha^2$, they will be the same value.

I'm sure there's a shorter route to the end there, perhaps by looking at the right-angled triangle to begin with; it represents the trajectory of the projectile without gravity.

share|improve this answer

Take the staring point as the origin for vectors. Then the trajectory is given by $$ \vec r(t)=\vec{v}_0t+\vec{g}t^2/2 $$ Suppose now that your target is at position $\vec{r}_1$, so we have to ensure that there exist a solution for $t$ of $$ \vec{r}_1=\vec{v}_0t+\vec{g}t^2/2 $$ Lets look at this equation solved for $\vec{v}_0$: $$ \vec{v}_0=\vec{r}_1/t-\vec{g}t/2\\ v_0^2=r_1^2/t^2+g^2t^2/4-(\vec{r}_1,\vec{g}) $$ We know what the value of $v_0^2$ is, so if the last equation has a solution, then we can just choose the direction given by the equation above. The rhs of last equation has a minimum wrt to $t$ with value (via AM-GM inequality) $r_1g-(\vec{r}_1,\vec{g})$. So, $$ v_0^2\ge r_1g-(\vec{r}_1,\vec{g}) $$ is the necessary and sufficient condition for being able to hit the target. Now, lets solve the equation $v_0^2=r_1^2/t^2+g^2t^2/4-(\vec{r}_1,\vec{g})$ (its biquadratic): $$ t^2=\frac{2}{g^2}\left(v_0^2+(\vec{r}_1,\vec{g})\pm\sqrt{(v_0^2+(\vec{r}_1,\vec{g}))^2-g^2r_1^2}\right) $$ These two solutions correspond to two distinct trajectories hitting the target. One will hit the target 'from above' ($+$ sign, greater time of flight), while the other will hit it 'not that much from above' ($-$ sign, shorter time of flight). Now you can pick your favorite sign and use $$ \vec{v}_0=\vec{r}_1/t-\vec{g}t/2\\ $$ to find the components of $\vec{v}_0$. For reference: $$ \vec{g}=(0,-g),\,\vec{r}_1=(x_1-x_0,y_1-y_0)\\ (\vec{r}_1,\vec{g})=g(y_0-y_1). $$

share|improve this answer
Sometimes I just dont get it why the question gets to the main page after 2 months or so.. –  Peter Kravchuk May 10 '13 at 17:24

If the span is defined as $\Delta x = x_1-x_0$ and $\Delta y = y_1-y_0$ then the following equations need to be solved for $t$ and $\theta$

$$ \Delta x = v\, t\, \cos\theta $$ $$ \Delta y = v\, t\, \sin\theta - \frac{1}{2} g t^2$$

One way to do this is to recognize that $\tan\theta = \frac{ y + \frac{1}{2} g t^2}{ x} $ and use it above (since $\cos \left(\tan^{-1}z \right) = \frac{1}{\sqrt{1+z^2}}$)

$$ \Delta x = \frac{v\,t\,\Delta x}{\sqrt{\Delta x^2 + \left( y + \frac{1}{2} g t^2 \right)^2 }} $$

to be solved for $t$ as

$$ t = \frac{\sqrt{2v^2-2g\Delta y-2\sqrt{v^4-2g v^2-g^2 \Delta x^2}}}{g} $$

and then back to $\theta$ as

$$ \tan\theta = \frac{v^2}{g \Delta x} - \sqrt{\frac{v^2 (v^2-2 g \Delta y)}{g^2 \Delta x^2}-1} $$


Shoot something $\Delta x = 500 \rm{m}$ across and $\Delta y = 20 \rm{m}$ up using a $v=100 \rm{m/s}$ projectile.

Gravity is $g=9.81 \rm{m/s^2}$. Plug above to get $t=5.23 \rm{s}$ and $\theta = 17.15 \rm{deg}$.

Here is a track of the projectile: Graph

share|improve this answer

You can use this formula to find the angle needed at which a projectile to be projected to cover a certain distance: $$\sin(2\theta) = \frac{gR}{V^2},$$ where $V$ is the initial velocity by which projectile has been projected $R$ is the distance up to which you want to throw the projectile or in your case difference between two $x$ coordinates i.e. $(X_1 - X_o)$

share|improve this answer
Just tidied your latex. By the way, the proper way to render trig functions is \sin, \cos, etc. If you just type "sin" it gets rendered as the product of three variables $s$, $i$, and $n$. :) –  Michael Brown Mar 8 '13 at 11:46
oh thank's this is my first time using this method to write something well thank's for your advice –  Dimensionless Mar 8 '13 at 11:48
Awesome! Thanks! I'm trying to work it into the equation now. I have one other question quick though. Now that i have the angle, how do i find a point along the projectile's trajectory given a time? –  NineBlindEyes Mar 8 '13 at 18:58
If time is given then you can find the height at which the projectile is and to what distance horizontally which will be your $Y$ and $X$ coordinate's –  Dimensionless Mar 8 '13 at 20:56
I don't think this answers the question. The question requires the path to pass through a specific point x1,y1. This equation will only yield an answer for a path to another x-value at the same height, e.g. x0,y0 to x1,y0. –  Phil H Mar 11 '13 at 13:30
