Here is a picture of our labview implementation of the code for this... It calculates angle based on the distance to the tower (horizontally), the height of the opening, and the velocity of the shooter.
It's split up to make it more readable, but is essentially a quadratic formula with three terms that are each calculated from the parameters. There are 2 quad formulas because in a normal parabola, the ball will cross the opening twice (once going up, once going down), so there are two solutions. We take the closer one.
Hope this helped!
__________________
2016 - NE District Championship Entrepreneurship Award
2016 - Hartford District Industrial Design Award
2016 - Waterbury District Engineering Inspiration Award