Trajectory optimization for maneuvering satellites