# Calculate velocity vector of hyperbolic trajectory

I am writing a little 2d space program and I need to calculate a velocity vector for my program. I already have my elliptical orbits working well but once the eccentricity of the orbit goes over 1 the velocity calculations fall apart.

Calculating velocity state vector with orbital elements in 2D

I used this thread as a reference and it worked perfectly for what I need. The top answer gave the the direction for the velocity. The vis-viva equation gave me the magnitude.

Does this equation work for hyperbolic orbits as well? It doesn't seem to be working for me. The x or y components seemed to be flipped depending on the the rotation of the orbit. I have also been unable to verify that it is producing the correct value anyways. I suspect that it is simply not the correct equation as the semi major axis is now negative in a hyperbolic orbit and the semi minor axis represents something else entirely.

Thank you!

• The vis-viva equation works perfectly fine with a negative semi-major axis. – SE - stop firing the good guys Feb 2 '20 at 20:39
• Yes! But the equation I linked : (−asinEcosω−bcosEsinω)i+(bcosEcosω−asinEsinω)j. doesn't work in my program. The visviva equation is as reliable as ever for me right now. Anyways I need the vector not just the magnitude – ryanq.feeney Feb 2 '20 at 20:41
• It's not at all clear what "this equation" means; can you copy and paste it here and explain exactly how you are using it? There are two answers there, you shouldn't make every reader here make their own guesses as to how you are using them. Thanks! – uhoh Feb 3 '20 at 1:28
• I'll edit the post to be more clear when I have more time but as I mentioned it is the top answer. The comment above yours has the equation in question: (−asinEcosω−bcosEsinω)i+(bcosEcosω−asinEsinω)j. I am trying to determine the velocity vector of my satellite. I have the eccentricity anomaly. This equation works perfectly for elliptical orbits for eccentricity between 0 and 1 – ryanq.feeney Feb 3 '20 at 22:50