Optimal low-thrust transfers in two-body and three-body dynamics