Optimal thrust control with magnitude and direction constraints