Jump to content

Calculating the correct altitude over water


Nereid

Recommended Posts

I'm still facing the problem to calculate the correct altitude for a radar altimeter in NanoGauges over see/water.

Over terrain it's easy: subtract terrain height from altitude. Over water... well, this will create a desaster. In this case the radar altimeter should display the altitude above sea level.

So, question: Is there a way to detect if a vessel is flying over water? is there a better way to calculate the radar altitude?

Thanks for any tip.

Link to comment
Share on other sites

Assuming your issue is that radar alt is going to the seabed

Math.Min(radarAlt, vessel.alt)

Well, this wont work, because on Mun there is no water and some terrain is below height 0. :(

- - - Updated - - -

I thought water was always at "height" 0? If it's not, then maybe you can check the RSS code to see what they change to get the water level to be at the proper height?

Yes water height is 0. But if there is no water and terrain is below 0, we cant assume radar altitude = altitude (above sea level).

Link to comment
Share on other sites

The fix to the Math.Min shown above is to gate it behind a CelestialBody.ocean check.

If .ocean is true, that body has a sea, if false it does not.

D.

This will only work if no celestial body (with .ocean=true) has terrain below 0 without an ocean. But to be honest I don't know if KSP supports such strange terrain.

Link to comment
Share on other sites

That is one of the oddities of KSP.

If a body .ocean = true, that body has a "water sphere" that is perfectly round at an ASL of 0 so you can never go to a "negative" altitude, you hit water at ASL 0 first.

It's (one of) the reasons moving your camera so you can't see the ground during launch can result in such a large FPS increase, KSP is drawing two "grounds", one is the terrain you can land on, one is the water "ground" sphere. KSP draws both of them, you just see whichever one has a higher altitude.

D.

Link to comment
Share on other sites

That is one of the oddities of KSP.

If a body .ocean = true, that body has a "water sphere" that is perfectly round at an ASL of 0 so you can never go to a "negative" altitude, you hit water at ASL 0 first.

D.

Ah, ok. If this is true than we have a very simple way to calculate the true (radar) altitude. Thanks :)

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...