Skip to content

from_state_vector: Fixed assertion error for retrograde non-inclined orbits#48

Open
mgiuca wants to merge 4 commits into
RazerM:masterfrom
mgiuca:from_state_vector-flat-retrograde
Open

from_state_vector: Fixed assertion error for retrograde non-inclined orbits#48
mgiuca wants to merge 4 commits into
RazerM:masterfrom
mgiuca:from_state_vector-flat-retrograde

Conversation

@mgiuca
Copy link
Copy Markdown
Contributor

@mgiuca mgiuca commented Sep 16, 2025

This was calculating both raan and f as nan, since i=180° was going into the inclined orbit code path, when it is actually non-inclined. When invoked via KeplerianElements.from_state_vector, the nan value would fail an assertion.

This also adds an important case needed to get the correct value of arg_pe for retrograde non-inclined orbits: if i=180°, arg_pe needs to be inverted since the orbit itself is upside down. Added two regression test cases for this case.

Fixes #18 and #25.

This is intended to be based on top of PR #47.

Adds a missing check for the case where the eccentricity vector is in the third
or fourth quadrant, requiring arg_pe to be negated.

Note that this causes an edge case where arg_pe should be 0° but it comes out as
360° because we are not using modulo, but rather adding 2*pi. I didn't want to
fix that in this commit because all the calculations in from_state_vector behave
the same way.

Fixes RazerM#39.
When negating an angle, consistently use mod 2*pi instead of adding 2*pi. This
causes 0 to remain as 0 instead of becoming 2*pi.
This was caused by missing check for the case where e ~= 0 when orbits are
inclined, thus dividing by the eccentricity resulted in a divide-by-zero.

Fixes RazerM#38.
…orbits.

This was calculating both raan and f as nan, since i=180° was going into the
inclined orbit code path, when it is actually non-inclined. When invoked via
KeplerianElements.from_state_vector, the nan value would fail an assertion.

This also adds an important case needed to get the correct value of arg_pe
for retrograde non-inclined orbits: if i=180°, arg_pe needs to be inverted since
the orbit itself is upside down. Added two regression test cases for this case.

Fixes RazerM#18 and RazerM#25.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Elements from state vectors does not work for Orbits with 180° inclination.

1 participant