I'm going to put an origin at the point of firing and use a +x direction in the direction of the oncoming ship and +y directly upward.
The key to doing this is you have to aim the projectile at where the boat is going to be when the projectile gets to the water level. So the range of the projectile is going to have to be:
From the projectile part of the problem we know that
Combining these two gives us:
Again, from the projectile part of the problem we know that the final height of the projectile is the same as the initial, so
So we have two equations in two unknowns to solve:
There are two typical ways to solve this equation:
1) Solve the x equation for cosine and the y equation for sine, then use .
2)Solve the x equation for t and substitute into the y equation. Then solve the trigonometric equation.
I'm going to use 1):
<-- Multiply both sides by :
<-- Now I'm going to plug in and simplify:
We can solve this numerically, and I get that:
(These are the only two positive solutions, the negative solutions being unphysical.)
So now we can find the projection angles:
which is impossible.