DMagic

[1.4.x] DMagic's Basic Mods - Basic Orbit v8.3 & Basic DeltaV 3.2[9-11-2018]

Recommended Posts

Doing a quick audit, I'd double check that this does what it's supposed to in a debugger:

https://github.com/DMagic1/KSP_BasicOrbit/blob/12c3411589440381ab1540ebf3e13890ceb9b038/Source/BasicOrbit/BasicExtensions.cs#L34

        public const double AlmostMaxValue = double.MaxValue - 1000;

The distance between adjacent representable values isn't constant for floating point numbers (and grows as the numbers grow), so I would suspect that AlmostMaxValue is getting set equal to double.MaxValue here as the "- 1000" gets lost to a rounding error. That would then cause this check to fail:

https://github.com/DMagic1/KSP_BasicOrbit/blob/12c3411589440381ab1540ebf3e13890ceb9b038/Source/BasicOrbit/Modules/ManeuverModules/BasicManeuvering.cs#L583-L584

				if (dist1 > BasicExtensions.AlmostMaxValue && dist2 > BasicExtensions.AlmostMaxValue)
					return false;

... since the two values being checked are equal. That then allows the code after that to run with dist1 = double.MaxValue.

https://www.exploringbinary.com/the-spacing-of-binary-floating-point-numbers/

Quote

Those Gaps Get Huge

It’s easy to lose feel for the magnitude of these gaps. For example, in the neighborhood of 1e300, which in double-precision converts to 1.01111110010000111100100010000000000001110101100111 x 2996, the gap size is a whopping 2944. This explains why adding 1, 10000, or even

74350845423889153139903124907495028006563010082969722952788592965797032858020218677258415724807817529489936189509648652522729262277245285389541529055119731289148542022372993697134320491714886843511959789117571860303387435343894004407854947017432904150602255272707195641188267440734208

(that’s 2943) to 1e300 still gives you 1e300. (2943 is half the gap size, but the result rounds down to due round-half-to-even rounding.)

 

Share this post


Link to post
Share on other sites

@HebaruSan Yep, I was thinking the same thing. I changed it to double.MaxValue / 10, made it >=, and checked the values individually instead of both at the same time.

I have a handful of other small updates to this and Basic DeltaV that I'll release some time soon.

  • Like 2

Share this post


Link to post
Share on other sites
6 hours ago, DMagic said:

@ZobrAA Do you know what the actual closest approach value is when that happens? It looks like some impossibly large value is getting calculated for some reason.

And does the same thing happen if you open the map view?

That number is the max value of a 64 bit floating point value in c#. Basic Orbit should be checking for such a possibility, but it looks like an error could have slipped through.

It's flickering - one second it show right numbers, than glitches, than normalize again and this bug showed only far from the planet in my enlarged Kerbal system. I've failed to find exact situation when it starts to happen.

Share this post


Link to post
Share on other sites

Hey first and foremost, great mods. 

I stumbled upon them and made a switch from KER as I loved the style as well as being a fan of your other mods. 

Secondly, having searched the topic and read the first post, am I correct in saying that TWR in basicDV is the maximum value? If so would there be a possibility in having a secondary based on thrust? It is the only thing I miss from KER

So for example TWR: CurrentThrustSettings TWR (Max TWR currently possible). 

Don't know if I explained that right (if it makes sense) or I am just missing something out. 

Share this post


Link to post
Share on other sites

@rakol That's one of the things I've already changed for Basic dV in flight for the next update. The display for the current stage will show the actual TWR (and thrust), and the max values in parenthesis.

Share this post


Link to post
Share on other sites

Basic Orbit 8.3 and Basic DeltaV 3.2 are available on Space Dock now (GitHub seems a little backed up, so the latest versions aren't posted there yet).

Both have fixes for the toolbar icon being fuzzy in some cases.

Basic Orbit has fixes for the closest approach and radar height calculations.

Basic DeltaV shows the current thrust and TWR for the active stage readout panel in flight.

  • Like 2

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now