Calculating Launch Angle Given Distance with Added Height (which itself depends on launch angle) In my physics class we have learned to calculate a desired launch angle to allow a projectile to hit a target given the target’s distance away and the initial velocity. 
Now in this case the initial velocity of the projectile occurs at the axis of rotation of the so called “cannon” that is launching the projectile. But what if the initial velocity occurs at the tip of the cannon? When the launch angle changes, so does the launch height and the distance to the target. 
With this added information I was NOT able to solve for the desired launch angle using the kinematic equations of motion. Is this problem possible to solve? 
Please see the attached pdf for a better visualization and the equations
As requested by a comment, here is the equation I couldn’t solve for $\theta$:
$$d - r \cos(\theta) = \frac{ v \cos(\theta) }{-g} \cdot  \left( -v \sin(\theta)\pm \sqrt{\bigl(v \sin(\theta)\bigr)^2 + 2g \bigl( h + r \sin(\theta) \bigr) \vphantom{\Big|}}\right)$$
This question has been asked before here but not answered.
 A: In the simple case
$x(\theta, t) = v (\cos \theta) t\\
y(\theta, t) = v (\sin \theta)t - \frac 12 g t^2$
Where $v$ is your launch velocity.  $\theta$ is your launch angle, $t$ is time, and $g$ is your gravitational constant.
Based on the picture, you have the cannon at some initial altitude, $y_0$.
$x(\theta, t) = v (\cos \theta) t\\
y(\theta, t) = v (\sin \theta)t - \frac 12 g t^2+y_0$
Then end of your cannon is just one more translation.
$x(\theta, t) = v (\cos \theta) t + d\\
y(\theta, t) = v (\sin \theta)t - \frac 12 g t^2+y_0 + h$
But it might help if you see that $\frac {h}{d} = \tan \theta$ 
and the length of the barrel  $l = \sqrt {h^2+ d^2}$
$x(\theta, t) = v (\cos \theta) t + l\cos\theta\\
y(\theta, t) = v (\sin \theta)t - \frac 12 g t^2+y_0 + l\sin\theta$
A: We can still account for this!
Let's note down all relevant information. 
Our initial height can be $h_0$, and then we can call the cannon length $r$. 
We have that our INITIAL height is $h_0+r\sin(\theta)$.
In addition, if the target is distance $d$ away, the distance the cannon must travel is $d-r\cos(\theta)$.
I think that's fair. 
Let's make one quadratic that expresses height in terms of time. We want to get the point where height=$0$, because that's where it hits the ground. 
We have that $-\frac{1}{2}gt^2+vt\sin(\theta)+(h_0+r\sin(\theta))=0$
We also need to record the horizontal distance it travels, so we know how far the cannonball went.
We know that the horizontal speed must be $v\cos(\theta)$, so we know that $vt\cos(\theta)=d-r\cos(\theta).$
Things to note: $h_0,v,g,r$ all constants.
Same with $d$. So really, we have a system of equations in $t$ and $\theta$. 
Two-equations, two-variables. You got this!
