I have a ship, the ship travels towards a heading (vector3, blue arrow) with an arbitrary speed.
The ship has a weapon on the side, the weapon can point in any direction, except straight forward/backwards from the ship heading. (In example image the weapon is a perpendicular 90* right).
The weapon has a firing arc, in n degrees (so, n/2 degrees in either side from the weapon "point direction").
Given a target at any position on the same side of the ship as the weapon (red circle), how do I rotate the ships heading so that when oriented towards the new heading (in this example, the yellow arrow), the target is inside the bounds of the firing arc? (The ship cannot rotate on the spot, it turns by driving forward towards a heading, like a simplified aircraft)
While my game is set in full 3D, I think a 2D solution will be more than enough. I use Unity, and C#, but I'm thankful for any solutions.
Edit: To clarify, I am looking for the "math-based" solution, collision-checks etc isn't really feasible.