-
Notifications
You must be signed in to change notification settings - Fork 40
Description
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.