Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

My goal is to compute an angle + velocity combination to hit a target at point $(x,y)$ in exactly $t$ seconds. (Uniform gravity, no drag, no wind)

I know that the general formula for trajectory is:

$x = vt \cos \theta$,

$y = vt \sin \theta - \frac{1}{2} g t^2$.

But the problem is I think I can't solve the equation with only 2 inputs, $x$, $y$ and $t$.

Any ideas would be gladly appreciated, thank you for your brain time.

share|improve this question
2  
I believe this is related to projectile motion and should be there in any fundamental physics textbook. –  dineshdileep Jan 9 '13 at 10:56

2 Answers 2

up vote 2 down vote accepted

Note that $(v t\cos(\theta))^{2}+(vt\sin(\theta))^{2}=v^{2}t^{2}=x^2+(y+\frac{1}{2}gt^{2})^{2}$ which gives $$v=\frac{\sqrt{x^2+(y+\frac{1}{2}gt^{2})^{2}}}{t}$$ Now it is fairly easy to get $\theta$ from $x=vt\cos(\theta)$.

share|improve this answer
    
Did you ever convert this to code? –  Matt W Jul 16 '13 at 9:33
    
No. But that should be fairly easy... –  Dominik Jul 16 '13 at 16:08
    
How about this: brackets = y + .5 * g*t ^ 2; equation = (x^2) + brackets^2; v = math.sqrt( equation ) / t; –  Matt W Jul 16 '13 at 16:20
    
I'm just not sure how to get theta from 'x=vt cos(theta)' –  Matt W Jul 16 '13 at 16:22

From the first equation,

$$ v t = \frac{x}{\cos{\theta}} $$

Plug this into the second equation:

$$ y = x \tan{\theta} - \frac{1}{2} g t^2 $$

Rearrange and solve for $\theta$. Then use the first equation to solve for $v$. Use the fact that

$$ \cos{\tan^{-1}{z}} = \frac{1}{\sqrt{1+z^2}} $$

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.