Algorithm for Low Thrust Optimal Interplanetary Transfers with Escape and Capture Phases