A Method to Solve Nonlinear Optimal Control Problems in Astrodynamics