How to Shape the Mainsail for Beating