# Solving for theta of a projectile over uneven ground

#### Hairchrm

Hello- I put this question in this forum because I didn't really think it fell under "trigonometry", and this was the only category that seems to somewhat fit.

I am modeling a projectile on a computer program, and need a formula to solve for the angle necessary for a projectile shot at a given velocity to hit a target a given distance away, but not over flat ground, ie the target is higher or lower than the initial position of the projectile. Solving for theta over flat ground is fairly trivial, but I cannot solve for theta over uneven ground. First, is there even a closed form solution? Secondly, here is what I have so far--

v= velocity of the projectile
$$\displaystyle \theta$$= the angle it is being launched at

First the parametric equations-
$$\displaystyle y = vtsin(\theta) - \frac{gt^2}{2}$$
$$\displaystyle x = vtcos(\theta)$$

So $$\displaystyle t = \frac{x}{vcos(\theta)}$$

Substituting in t,
$$\displaystyle y = \frac{vxsin(\theta)}{vcos(\theta)} - \frac{gx^2}{2v^2cos(\theta)^2}$$
which simplifies to
$$\displaystyle y = xtan(\theta) - \frac{gx^2}{2v^2cos(\theta)^2}$$

Using normal trig methods, I could not solve this equation for theta. Asking a teacher, she suggested I use Euler's identities because sometimes those are easier to work with than trig identities. So I converted

$$\displaystyle sin(\theta)$$ to $$\displaystyle \frac{e^{i\theta} - e^{-i\theta}}{2}$$

and $$\displaystyle cos(\theta)$$ to $$\displaystyle \frac{e^{i\theta} + e^{-i\theta}}{2i}$$ to see if I could work it that way...

After manipulation, it comes out to-

$$\displaystyle e^{i\theta} = \frac{-igx \frac{+}{} \sqrt{4y^2v^4-g^2x^4-4x^2v^4}}{2v^2(y-ix)}$$

$$\displaystyle \theta = i ln(\frac{-igx \frac{+}{} \sqrt{4y^2v^4-g^2x^4-4x^2v^4}}{2v^2(y-ix)})$$

Which has an imaginary part. When I plug in what the known values for x and y are for theta = $$\displaystyle \frac{\pi}{4}$$ and v = 100, this formula returns theta as imaginary, which is obviously incorrect since I know it should return $$\displaystyle \frac{\pi}{4}$$. Did I go wrong somewhere? This problem cannot be new- has anyone else solved this, or know of a way to solve it? Thanks for your help!

#### lvleph

I always tell my students to solve the quadratic
$$\displaystyle y = vt\cdot sin(\theta) - \frac{gt^2}{2}$$
Because this one will give you two solutions one being $$\displaystyle t \le 0$$.
If $$\displaystyle t = 0,$$ this is absolutely a solution, but it doesn't satisfy the $$\displaystyle x$$ equation, for $$\displaystyle x>0$$, so it must be thrown out. Clearly, $$\displaystyle t < 0$$ is not a solution. Anyway, that leaves
$$\displaystyle t = \dfrac{v\cdot \sin \theta + \sqrt{v^2\cdot \sin^2 \theta - 2g\cdot y}}{g}.$$
Now plug this in for $$\displaystyle t$$ in the $$\displaystyle x$$ equation.

#### Hairchrm

Ah, thanks so much. I can't believe I didn't think of doing that before. In case anyone else is wondering, the answer turns out to be--

$$\displaystyle \theta = arctan(\frac{2v^2 \frac{+}{} v^2 \sqrt{4- \frac{4g^2x^2}{v^4} - \frac {8gy}{v^2}}}{2gx})$$

Thanks again.

#### kintovt

Hi, i'm trying to solve the same task. This is a very old topic, but I hope that someone can help.

I have some problems with understanding this part of the answer:

$$\displaystyle \frac{+}{}v^2$$

Can it be some misspelling?

Last edited: