What is the angle to launch projectile in 2D, given destination displacement and initial velocity? Description of the problem
I want a projectile launched at speed $v_0$ at angle $\theta$ above the horizontal to just make it to the top of a building of height $h$ and a distance $d$ away. What $\theta$ should I use?
What have I tried?
Let $t^*$ be the moment when the projectile just makes it to the top of the building.
I'm using the following functions to represent displacement for both $x$ and $y$
$y(t^*) = y_0 + v_{y0}t^* + \frac{a_y{t^*}^2}{2}$
$x(t^*) = x_0 + v_{x0}t^* + \frac{a_x{t^*}^2}{2}$
where $v_{x0}$ and $v_{y0}$ represent the initial velocities along x-axis and y-axis respectively. The relationship between $v_0$, $v_{x0}$ and $v_{y0}$ via angle $\theta$ is
$v_{x0}=v_0 cos(\theta)$
$v_{y0}=v_0 sin(\theta)$
$tg(\theta)=\frac{v_{y0}}{v_{x0}}$
We know that $y_0$, $x_0$ and $a_x$ are $0$, as well as $a_y=-g$. Also, $y(t^*)=h$ and $x(t^*)=d$.
Therefore, the above equations are simplified to
$h = v_{y0}t^* - \frac{g{t^*}^2}{2}$ $(1)$
$d = v_{x0}t^*$ $(2)$
We assume that $v_{x0} \neq 0$ and derive that $t^*=\frac{d}{v_{x0}}$ from equation $(2)$.
We then substitute $t^*$ in the equation $(1)$ and end up with the following
$h = v_{y0}\frac{d}{v_{x0}} - \frac{g({\frac{d}{v_{x0}}})^2}{2}$
$h = tg(\theta)d - \frac{g d^2}{2 {v_{x0}}^2}$
$h = tg(\theta)d - \frac{g d^2}{2 {v_{0}}^2 cos^2(\theta)}$
Where am I stuck?
I don't know how to solve this trigonometric function.
I looked at the answer in the book, and it says that the solution is
$\theta = tg^{-1}(\frac{2h}{g})$
Based on the answer from the book, I'm failing to see how my approach resolves to that number, given that the answer from the book doesn't depend on $v_0$. I'm not sure if that is possible though, so could it be a mistake in the book?
If there is no mistake in the book, I think that there is a flaw in my approach and I would appreciate if anybody could give me a hint or any directions on how to solve this question.
 A: I think your problem was at equation (1), you didn't it and the time squared convoluted your following equations.
I propose:
Whenever possible avoid using equations of motion. Try solving the problem through energy conservation.
$ E_0 = \frac{1}{2}m(u_{x0}^2 + u_{y0}^2) $
$ E_{top} = \frac{1}{2}m(u_{x0}^2 + 0^2 )+ mgh $
From energy conservation you can find $u_{y0}$
Then you can use the equations of motion for a relation between $u_{x0}$ and $u_{y0}$.
Namely: $u_y(t_{end}) = 0$ and $x(t_{end}) = d = u_{x0}t_{end}$
This will give you a relation between $u_{x0}$ and $u_{y0}$ with constants only.
Now what's the relation between $u_{x0}, u_{y_0}$ ? it's $tan(\theta)$
All the pieces are on the table now .
A: With your two equations (1) and (2), with 2 unknowns t and θ, eliminating t led to a complex expression for θ.  Try using $sin^2$(θ) + $cos^2$(θ) = 1 to eliminate θ.  This leads to a quadratic equation in $t^2$.  Use this to get t and then  θ from equation (2).
If you are given an initial velocity, this approach gives two possible angles to hit the top edge of the building. If you want to "just make it", the time is minimized and the two angles converge (the square root in the quadratic is zero). For this, the methods suggested by other answers would be quicker.
