I'm writing a little project that simulates an orbit by converting from initial state vectors $\vec{r}$ and $\vec{v}$ to Keplerian elements, then converting back to $\vec{r}$ and $\vec{v}$ from those Keplerian elements, but stepped one frame ahead. I'm having some trouble with that last part.
I've been using René Schwarz's conversion guide quite a lot, but the transformations and rotations at the end honestly just confuse me, so I ended up just using the True Anomaly and $|\vec{r}|$ to calculate the new $\vec{r}$, which does seem to work, but I'm stumped on how to calculate $\vec{v}$, I have the equation for the velocity at any point on an orbit with
$$v^2 = \mu \left(\frac{2}{|\vec{r}|}-\frac{1}{a}\right)$$
Where I just plug in the new $|\vec{r}|$ and I get $|\vec{v}|$, but trying to use this equation for the tangent vector to any point on an ellipse given the angle, $$-a \cos\theta i + b \cos\theta j$$
Where $a$ is the semi major axis, $b$ is the semi minor axis, and $\theta$ is the angle around the ellipse (I've been using the True Anomaly as input for that angle, is that correct?) doesn't seem to work to find the vector tangent to the ellipse. So my questions are:
How do I find the vector tangent to a 2D orbital ellipse given $e$ and $a$, as well as $|\vec{r}|$, $|\vec{v}|$, and the True, Eccentric, and Mean anomaly at that point? (I also have some additional elements that I haven't used yet such as the argument of periapsis if that's useful.)
How do I determine which direction that vector should face (so it doesn't point toward retrograde when it should point towards prograde) given the same values as above?
+1
for a great rewrite! :) In this case there might be an existing answer here that answers your question. I know there have been at least a few somewhat similar questions. If your question ends up being marked as a duplicate by pointing to an existing answer, don't think of it as a bad thing. It's just stackexchange's way of making sure future readers are guided to fewer, but higher quality answers. If it doesn't help, please say so, and remember you can ask as many more (quality) follow-up as well as totally new questions as you like! $\endgroup$