I'm here once again because I can't figure this out. I'm building an orbit simulator and currently working on placing the ship on a hyperbolic trajectory upon entering the SoI of a body. (I'm using patched conics in 2D.) I'm having an issue with the math though, where the orbit is calculating all the correct parameters, but the ship is ending up in the wrong spot.
I tracked the problem down to the point where the current hyperbolic anomaly (F) is calculated from the current mean anomaly (M). Based on a previous question I asked, I'm using the Newton-Raphson method (based on this) to find F:
for(int i = 0; i < 10; i++) {F = F - (((e * sinh(F)) - F - M) / ((e * cosh(F)) -1));}
The problem is that I'm not getting a symmetrical result from M -> F as from F -> M. A ship that has
nu0 = -0.5346949277282228
F0 = 0.04402263120230271
M0 = 5.793100753021599E-4
gets
M = 5.793100753021599E-4 (good)
F = 0.01027520200339216 (wrong)
nu = 0.1276522417546593 (also wrong)
It ends up at the wrong point on the orbit and nothing else is right.
To try to narrow down the problem, I graphed the equations to visualize what they were doing. In this graph, I have both the hyperbolic equation and my method of solving it. The first graph, M from E, does what I would expect: smoothly curves from (-pi, -infinity) to (+pi, +infinity). That's what the proper shape of a hyperbolic orbit is. I would expect the Newton method to give a perfect inverse, going from (-infinity, -pi) to (+pi, +infinity). But that's not what it does, it has a couple weird humps near 0,0, but otherwise goes from (-infinity, -infinity) to (+infinity, +infinity). The asymptote is sloped, not horizontal.
I also did the same thing with the elliptical case, and it produced a perfect inverse equation, exactly as I expected. But the hyperbolic equivalent does not, and I am completely lost as to why. I've tried numerous different forms of the equation, but they all give this same shape. I've tried different starting guesses and parameters, but none give me the mirrored function I want.
Am I doing something wrong? Is this actually right and I'm just misleading myself? I've taken calculus but not enough to diagnose this myself. Hopefully it's something simple that I'm doing wrong.