Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in phaseAngle function in lib_navigation.ks #141

Open
nuggreat opened this issue Dec 24, 2021 · 0 comments
Open

Bug in phaseAngle function in lib_navigation.ks #141

nuggreat opened this issue Dec 24, 2021 · 0 comments

Comments

@nuggreat
Copy link
Contributor

A user on the kOS discord server reported an issue with the phaseAngle function in lib_navigation.ks where for some targets the returned phase would be negative when it shouldn't. The cause of the issue is that when summing the net velocity vector from SHIP to the common_ancestor no allowance was made for the fact that the magnitude of SHIP:BODY:VELOCITY:ORBIT would be zero due to the velocity reference frame used by kOS has the body the ship is in orbit around as it's origin.

The steps for reproduction:

get a craft on kerbin or in kerbin orbit
then run

RUN lib_navigation.ks
SET TARGET TO duna.
UNTIL FALSE {
  PRINT phaseAngle().
  WAIT 0.
}

then time warp fast enough to see days pass and the phase angle will flip between pos and neg when it shouldn't.

The fix is likely simple enough as calling body:ORBIT:VELOCITY:ORBIT gets the orbital velocity vector of the given body with the origin of that vector based on the parent bodies velocity.

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

No branches or pull requests

1 participant