I'm simulating an interplanetary trajectory between two spheres of influence. I have already simulated a hyperbolic escape within the sphere of influence and have arrived at the boundary of the sphere of influence of the starting planet, where I'm trying to patch the escape hyperbola conic to an hohmann transfer ellipse and determine how long it will take to reach the other planet's sphere of influence (where I would need to patch from the hohmann transfer ellipse to another hyperbola within the destination planet's sphere of influence). In the simulation I can simply do this by trial and error (i.e. simulate the trajectories of the transfer ellipse and see when it falls within the sphere of influence's radius).
However, I was wondering if there is a way to do this analytically using orbital mechanics principles. Given that I have the spacecraft's initial position and velocity with respect to the sun (and therefore can derive all other orbital elements as required), as well as the destination planet's initial position and velocity w.r.t. the sun, how can I find the time of flight to reach the sphere of influence of the destination planet?
I think the key to solving this problem lies in parameterizing the true anomalies of the spacecraft's trajectory and the planet's trajectory as a function of time and starting anomaly. Is there a way to do this?