from_state_vector: Fixed arg_pe bug where orbit is very slightly inclined#50
Open
mgiuca wants to merge 7 commits into
Open
from_state_vector: Fixed arg_pe bug where orbit is very slightly inclined#50mgiuca wants to merge 7 commits into
mgiuca wants to merge 7 commits into
Conversation
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.
…tion. This abstracts the repeated code that finds the unsigned minimum angle between two vectors using acos to a standalone function.
This was caused by the argument to acos being slightly higher than 1.0 due to rounding errors, resulting in nan (when it should just be 0). Fixes RazerM#40.
…ined. If the Z coordinate is negative, but the inclination is extremely small, it triggers the non-inclined case, which hard-codes raan to 0, yet still runs the code path which inverts arg_pe if ev.z < 0. This code path only makes sense if raan is also rotated 180°, which it is not. Moved the ev.z < 0 code path into the i-not-small condition. This also makes the code more readable, as now all the code that sets arg_pe is in one place. Added regression test cases for this issue. Fixes RazerM#44.
Contributor
Author
|
That's the last one for now :) I didn't realize GitHub doesn't let me make a PR that only shows the changes between two of my own branches, so if reviewing all of these PRs at once, you will need to look at the individual commits, not the whole PR which contains the changes from all previous PRs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If the Z coordinate is negative, but the inclination is extremely small, it triggers the non-inclined case, which hard-codes
raanto 0, yet still runs the code path which invertsarg_peifev.z< 0. This code path only makes sense ifraanis also rotated 180°, which it is not.Moved the
ev.z< 0 code path into thei-not-small condition. This also makes the code more readable, as now all the code that setsarg_peis in one place.Added regression test cases for this issue.
Fixes #44.
This is intended to be based on top of PR #49.