The value of vessel.orbit.semi_major_axis is wrong. This is easily shown by comparing this value to an in-script calculated SMA, see code below.
code to reproduce:
use { CONSOLE } from ksp::console
// ensure an elliptical orbit, having an eccentricity clearly > 0
pub fn main_flight(vessel: ksp::vessel::Vessel) -> Result<Unit, string> = {
CONSOLE.clear()
let sma_calc = vessel.main_body.radius + (vessel.orbit.apoapsis.value + vessel.orbit.periapsis)/2
let sma_field = vessel.orbit.semi_major_axis
CONSOLE.print_line("calculated sma :" + sma_calc.to_fixed(4))
CONSOLE.print_line("vessel.orbit.semi_major_axis :" + sma_field.to_fixed(4))
}
Possible cause:
Wrong assignment in KSP2Runtime/KSPOrbit/OrbitWrapper.cs at line 32:
public double SemiMajorAxis => orbit.SemiMinorAxis;
This would explain why it went undetected, as semi-minor axis and semi-major axis converge for eccentricity -> 0. I am neither an expert in C# nor modding, so this is just an educated guess. :)
KS2 0.4.1 / KSP 0.1.2.0.22258
The value of
vessel.orbit.semi_major_axis
is wrong. This is easily shown by comparing this value to an in-script calculated SMA, see code below.code to reproduce:
Possible cause: Wrong assignment in KSP2Runtime/KSPOrbit/OrbitWrapper.cs at line 32:
This would explain why it went undetected, as semi-minor axis and semi-major axis converge for eccentricity -> 0. I am neither an expert in C# nor modding, so this is just an educated guess. :)