My Lambert Solver will plot a course that will intercept any target body. However, really it is only aware of your start, end and centre of attraction. If your course involves departing from an orbit around Luna heading for Titan then Lambert gives you a Sol relative velocity to match and doesn’t care about the effects of gravity from Luna, Earth or the fact that your course might well take you on a collision course with either.
They are problems that can be solved, or at least accounted for. But a more insipid issue is also at play. The Lambert Solution doesn’t care if you pass within the gravitational influence of anything along the way. It knows nothing of the various planets or moons whose orbits you cross along the way to your destination. So once Lambert suggests a course, we need to see if it brings us too close to some other bodies. We need to predict encounters, that is, determine the time that a point (ship) moving on a conic path is a set distance from another point (planet/moon) on a separate conic.
Guess what turns out to be really hard?
I was able to find research papers on determining the closest approach between two objects, but they were beyond my understanding, referencing topics in maths way passed what I know, and even then you would have the theoretical closest point, no information as to if they actually are ever near each other at the same time. Now knowing the minimum distance would have use, but I couldn’t fathom it.
Then, around Christmas I downloaded and tried a game I’d heard about since early in it’s development, I’ve followed it’s progress ever since the main guy behind it was looking for information on the Orbiter forums about ways to present orbital mechanics simply in a game around the same time I was using them for research. The game is Kerbal Space Program, a 3D rocketry sim about designing rockets and trying to get them to space. Once I got over the malaise of seeing how much he had accomplished over the same time that I’ve been floundering (mainly as it’s his job and works with a team and I scrape together time usually when I’m already too tired to juggle rocket science) I saw that he was predicting encounters.
His spacecraft would project their path and he would detect where/when it was going to touch the sphere of influence of a body and use that to calculate a series of Patched Conics. So, I went back to the orbiter forums and asked him, and he explained at a high level. As I’m using 2D some further options are available to me than to the 3D scenario he has, but the idea will be basically the same. Use orbit size tests as a first pass rule out, then find the closest pass point, then test for an encounter, then search backwards in time from there for the actual encounter point.
That search through time is potentially expensive and so I wanted to rule out potential candidates and narrow the ranges to search for the remaining ones. As my orbits are always co-planar I believe there is a chance that an encounter could occur after the closest point, as the orbit on the ‘inside track’ could catch up with the other as they were growing further apart, as such, I determine the segments of the ships orbit that are within the threshold of being able to encounter the body, i.e. between the bodies (periapsis – sphere of influence) and (apoapsis + sphere of influence.
I would like to know when it is actually in the accurate path of the body’s sphere of influence, but that is much more complicated and hopefully this isn’t so overzealous as to be an issue. This gives me the time and zone that an encounter could occur for the ship. I then determine where the body could be to have an encounter and where it will be when the ship could have an encounter. Getting the overlap of where the body will be and where it would need to be narrows the range, or rules out an encounter if it won’t be in the zone at the right time. Then using the times that the body will be in this narrowed range, if it exists, I determine where the ship will be while the body is in the target area. If these last two ranges are too far apart it rules out another candidate. Otherwise I have a narrowed range of time to test if an encounter exists and then to find the point when it first occurs.
Next is actually finding the point of encounter itself, if it exists…