# How to detect the correct sign of the true anomaly for position prediction (clockwise/counterclockwise rotation)?

I calculated spacecraft's keplerian orbital params from position/velocity using this formulas: https://drive.google.com/file/d/11KhEdFboZCPUjfibtjHaDBWtUTNmJxFA/view?usp=sharing

Then I can predict position by rotating orbit excentricity vector by true anomaly angle and multiplying it by radius length (after normalization). But sometimes I get the correct possition that points to the real spacecraft position and sometimes that position moves on orbit in opposite direction than spacecraft (if spacecraft rotates clockwise around planet, true anomaly moves counter clockwise and vise-versa), so, I need to select true anomaly with the minus sign to get the correct position in that case.

So, from which param of orbit the sign of true anomaly depends? How can I detect when I should use true anomaly with the minus sign?

True anomaly ($$f$$) is always measured in the direction of travel around the orbit; if, in your 2d simulation, the spacecraft is moving counterclockwise, then true anomaly is also measured counterclockwise from periapsis, and vice versa.

In a 2D simulation, the sign of the specific angular momentum value $$h = \vec{r} \times \vec{v}$$ determines whether the orbit is prograde (counterclockwise) or retrograde (clockwise).

Note that Argument of Periapsis $$\omega$$ is also always measured in the direction of travel around the orbit.

For the 2D representation, where $$e_x$$ and $$e_y$$ are the x- and y- components of the eccentricity vector, and the x-axis points in the reference direction, we have the following:

2D Spec. Ang. Momentum Orbit dir. 2D Argument of Periapsis Angle from Ref Direction
$$h= \vec{r} \times \vec{v}>0$$ Prograde $$\omega = \mathrm{arctan2}(e_y, e_x)$$ $$f + \omega$$
$$h= \vec{r} \times \vec{v}<0$$ Retrograde $$\omega = 2 \pi- \mathrm{arctan2}(e_y,e_x)$$ $$-(f + \omega)$$

Again, note that this is for a 2D simulation. In a 3D simulation, you must treat specific angular momentum as a vector, Prograde/retrograde is determined by the sign of the dot product of specific angular momentum and the z-axis, and the rotations required are more complicated.

• Hmmm, I tried r⃗ ×v⃗ >0 and it didn;t work. Maybe, I made some mistake in my calculations Nov 16, 2021 at 10:16
• I think I may have misunderstood what you were asking initially, and revised the answer based on the assumption that what you want to know is the direction of the orbit. Nov 16, 2021 at 10:18
• @Robotex Do you have the argument of periapsis in your calculations, or do I need to add how it is connected to the eccentricity vector? Nov 16, 2021 at 10:55
• @Robotex In Stack Exchange we use MathJax to get all kinds of math to render correctly. For example $\mathbf{r} \times$\mathbf{r} > 0$ yields $$\mathbf{r} \times \mathbf{v} > 0$$ and $\vec{r} \times $\vec{v} > 0$ yields $$\vec{r} \times \vec{v} > 0$$
– uhoh
Nov 16, 2021 at 13:15
• @notovny Thank you very much, you helped a lot. I also found an error in my calculation: I used dot product instead of cross product for momentum calculations (in 2D it is also a scalar), so, can't used it to detect the movement direction. Now, everything is ok. Nov 16, 2021 at 16:16