I have been trying to simulate a lunar free return trajectory using the state vectors for the Apollo spacecraft provided by JPL after they had performed their trans-lunar injection burn.

My understanding was that if something had gone wrong, the Apollo spacecrafts would just have swung around the moon and then back to Earth. However, in all of my simulations, disregarding which Apollo mission I'm using for the vectors, the spacecraft does not swing around the moon before coasting back to Earth, but enters a hyperbolic trajectory... Good bye brave astronauts :(

I'm wondering whether anyone could shed some light on whether this is because my algorithm is not powerful enough (tried super mega slow time-steps but you always get the same result), or if I have missed something?

  • $\begingroup$ Can you add a screenshot of the orbit? How close to the moon does it pass? What happens if you try changing your state vectors by a very small amount at a time? For example, if you just re-run your simulation and very slowly point closer to or farther from the moon, how much do you have to change to get it to pass within 100km of the moon? It could be very sensitive to the initial state vector, think about round-off. Also, how are you getting the exact position and velocity of the moon during the Apollo era? Are you using an ephemeris? $\endgroup$
    – uhoh
    Feb 13, 2017 at 14:55
  • 3
    $\begingroup$ Are you sending the craft into retrograde moon orbit direction, as you should? If you approach the moon "from behind", and try to enter prograde orbit (first flyby on the far side of the Moon) you'll get an accelerating assist that will eject you from the system. You need to pass "in front of it", exit "behind", do a "figure 8" relative to the Earth-Moon system. $\endgroup$
    – SF.
    Feb 13, 2017 at 15:34
  • 2
    $\begingroup$ Could you describe your simulation? Did you simulate the gravity forces of earth, moon and sun on the Apollo spacecraft for all the way from earth orbit to the moon? What about the simulation intervals in time and distance? $\endgroup$
    – Uwe
    Feb 16, 2017 at 21:24
  • $\begingroup$ Hey guys, sorry for taking my sweet time to reply; busy end to the week! $\endgroup$ Feb 18, 2017 at 13:36
  • $\begingroup$ Here's a link to the simulation: mrhuffman.nej/projects/gp and then you just select the Apollo 10 free return trajectory scenario. uhoh I get all the state vectors from ssd.jpl.nasa.gov/horizons.cgi#top. Tried changing the inputs but to no avail. Get within the gravitational influence of the Moon but after that the simulation breaks down, regardless of the time-step. SF, yes, vectors are from Nasa so I think the trajectory is correct. Uwe, I just simulate the earth moon system, no Sun, could that be it? $\endgroup$ Feb 18, 2017 at 13:43

2 Answers 2


This is a partial answer, hopefully it will lead to more discussion and a resolution.

I've found this animation of a free-return trajectory in what looks like earth-fixed "inertial" coordinates, at least the coordinates are not rotating with the Earth-Moon system.

Found at Robert A. Braeunig's Apollo 11's Translunar Trajectory and how they avoided the heart of the radiation belts.

Does your simulation aim for a spot in front of the leading edge of the moon?

This GIF is SLOW! Keep watching until complete!

enter image description here

  • 1
    $\begingroup$ Hi uhoh! Sorry for my dealyed reply; had one heck of a week at work, but I'm going to look at the link you sent me and see if it puts me on the right path; will get back to you shortly! $\endgroup$ May 20, 2017 at 12:55
  • $\begingroup$ @HappyKoala OK great! Sometimes it takes a while to set aside a block of time for projects like this. It's really an interesting orbit and one can learn a lot from it. $\endgroup$
    – uhoh
    May 20, 2017 at 13:01

Totally forgot about having asked this question, but fortunately I've been able to solve it. The were two problems: my integrator wasn't up for the task and you do have to include the Sun in a free return trajectory simulation as its gravitational influence on the Earth Moon system is not negligble, even on the time scale of days (at least with the integrator that I employed).

Here's the data I used for the scenario (Apollo 11, fetched from JPL Horizons), where g is the gravitational constant and dt is the time step. AUs for distance, years for time and solar masses for masses:

export default {
  name: 'Apollo 11 - Free Return Trajectory',
  g: 39.5,
  dt: 40e-7,
  distMax: 0.00713911058,
  distMin: -0.00713911058,
  distStep: 2.3797035266666667e-6,
  velMax: 0.5,
  velMin: -0.5,
  velStep: 5e-6,
  rotatingReferenceFrame: 'Earth',
  cameraPosition: 'Free',
  cameraFocus: 'Origo',
  freeOrigoZ: 16000,
  massBeingModified: 'Sun',
  primary: 'Earth',
  maximumDistance: { name: 'Moon to Earth * 10', value: 0.0256955529 },
  distanceStep: { name: 'Moon to Earth / 100', value: 0.0005139110579999999 },
  scenarioWikiUrl: 'https://en.wikipedia.org/wiki/Free-return_trajectory',
  masses: [
      name: 'Earth',
      x: 0.4240363252016235,
      y: -0.9248449798862485,
      z: -1.232690294681233e-4,
      vx: 5.622675894714279,
      vy: 2.5745894556521574,
      vz: 3.8057228235271535e-4,
      trailVertices: 2e4
      name: 'Sun',
      x: 0.004494747940528018,
      y: 9.145777867796766e-4,
      z: -6.127893755128986e-5,
      vx: -1.7443876658803292e-4,
      vy: 0.002043973630637931,
      vz: -4.697196039923407e-6,
      trailVertices: 2e4
      name: 'Moon',
      x: 0.4220528422463315,
      y: -0.9230209264977778,
      z: 1.632323615688905e-5,
      vx: 5.486589374929882,
      vy: 2.420601498441581,
      vz: -0.014677846271227611,
      trailVertices: 2e4
      name: 'Apollo 11',
      x: 0.4240447232851519,
      y: -0.9247715402118077,
      z: -1.129301018611092e-4,
      vx: 4.395253850175561,
      vy: 3.8323649107803948,
      vz: 0.15792573886687206,
      trailVertices: 15e4

export default [
    m: 0.000003003,
    radius: 91.74311926605505,
    color: 'limegreen',
    name: 'Earth'
    m: 3.69396868e-8,
    radius: 22.93577981651376,
    color: 'grey',
    name: 'Moon'
    m: 0,
    radius: 1.2,
    color: 'limegreen',
    name: 'Apollo 11'
    m: 1,
    radius: 90000,
    type: 'star',
    color: 'yellow',
    name: 'Sun'

And the result

  • 1
    $\begingroup$ @uhoh Thanks! Took me a while, but it was totally worth the effort :D. $\endgroup$ Dec 7, 2018 at 6:53
  • 1
    $\begingroup$ Oh yes! I'm actually working on implementing spacecraft with thrusting and attitude control, but before I can implement that feature I need to introduce an integrator with an adaptive time step, as discussed previously. I'm also trying to figure out how to procedurally generate the Moons of all the planets in the solar system so that you can travel from Earth to say Jupiter without having to wait for like 3 days (with the Moons the time step of the simulation has to be very slow (even with an adaptive one)). So when you would get say within the Hill Sphere of Jupiter... $\endgroup$ Dec 7, 2018 at 7:03
  • 1
    $\begingroup$ the integrator with the adaptive time step would slow the time step down and a distance to mass check would generate the Jovian system so that you could star thrusting around and say insert yourself into an orbit around ganymede. Not sure I'm conveying my thinking all that well, but I don't think it should be too tricky to fix. More than that I want to introduce collisions (also need the integrator with the adaptive time step for that!), particle systems for rings and galaxies, the ability to add masses with eccentric orbits (right now the masses you add will have circular orbits around... $\endgroup$ Dec 7, 2018 at 7:06
  • 1
    $\begingroup$ their primary. So yes, I'm not gonna let my baby collect dust... I'm doing this for the fun of it, and when I'm having fun the last thing I want to do is to call it quits :D. $\endgroup$ Dec 7, 2018 at 7:08
  • 1
    $\begingroup$ That's great news! If you are going to use our solar system, then you could probably use an ephemeris if you don't need absolute accuracy. For example in a few MB you could have known positions of everything at 1 week intervals (or less). Then you can get by with a lower accuracy integration only between ephemeris positions. Just a thought. $\endgroup$
    – uhoh
    Dec 7, 2018 at 7:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.