0
$\begingroup$

Given a coordinate and the launch speed, I need to determine which pair of angle, or angle allows a hit on said coordinate. I know, let's say, the common way, which is using the following equations:

$ x = V_ocos(\theta)t $ $ y = V_osen(\theta)t - \frac{gt^2}{2} $

And after removing the parameter:

$ y = tan(\theta)x - \frac{gx^2}{2{V_o}^2cos^2\theta} $

And solving for $tan(\theta)$: $ tan(\theta) = \frac{\frac{2{V_o}^2}{gx} \pm \sqrt{(\frac{2{V_o}^2}{gx})^2 - 4(\frac{gx^2+{2V_o}^2}{gx^2})}} {2} $

Now, that's big, plus there's too much margin for error. Do you know a better way to calculate the angle(s) of launch which hits $(x,y)$?

Thanks.

1 Answers 1

1

What do you mean by "too big"? It seems quite reasonable to me.

If you are worried about cancellation in an expression of the form $a \pm \sqrt{a^2-b}$, use the standard technique of computing the root with the sign of the $\sqrt{}$ having the same sign as $a$, and then use $(a \pm \sqrt{a^2-b})(a \mp \sqrt{a^2-b}) = a^2 - (a^2-b) = b $ to get the other root.