Jump to content

Vessel moving slower than its velocity under 100km


Recommended Posts

Hi,

I have observed something strange when orbiting around Kerbin at an altitude lower than 100km: the vessel is moving slower than its velocity. Here are the values I used:

- velocity is retrieved with vessel.obt_velocity

- position relative to kerbin is retrieved with vessel.GetWorldPos3D() - kerbin.position

- time is retrieved with Planetarium.GetUniversalTime()

- velocity from actual vessel movement is computed with (position1 - position0) / timeDelta

What I observe is that velocities are exactly the same for any altitude above 100km, but vessel movement is slower (by a factor of about 0.9) when under 100km. Anyone has an explanation?

Edited by Youen
Link to comment
Share on other sites

At orbital velocities the physics reference frame is the vessel unless I'm completely misremembering things (switchover ~700m/s, really obvious it's happened if you watch the exhaust smoke behaviour). There is a switchover around 100km (I don't remember the exact altitude) for terrain rendering but other than the altitude I don't recall anything linking the two.

I can't think of anything that would cause such a switch, but I would be checking on other related measurements to see if they change at the same altitude on Kerbin (eg. solar velocity, solar velocity less kerbin velocity, velocity direction, acceleration, etc.)

Link to comment
Share on other sites

The vessel velocity (as reported by obt_velocity) is coherent at all altitudes, and matches the expected orbital velocity. For example it's the same as vessel.orbit.getOrbitalVelocityAtUT(Planetarium.GetUniversalTime()).

vessel.orbit is also coherent and gives the correct orbit corresponding to Kerbin gravity.

So there is nothing wrong with any velocity I can read from KSP API.

The vessel position however does not match what it should. It follows the correct orbit, but slower than it should. vessel.orbit changes accordingly (same orbit, by time shifts to match the vessel moving too slowly along it). I haven't checked yet, but I think it will take more time than it should to make a complete orbit. I also haven't checked if other vessels are also moving slower than they should, or if it's only the player vessel. I will also check if I can observe the same behavior on another computer...

Edited by Youen
Link to comment
Share on other sites

Actually, @wasml is right ; the reference frame changes when going below 100km. Everything in vessel.orbit is in inertial frame when above 100km, but in rotating frame when below. It seems vessel.obt_velocity follows the same rules. My positions were always in the inertial frame (as said in OP, I use GetWorldPos3D() - body.position), which explains why it didn't match below 100km. I probably made much more knots in my head than needed be, some of the things I said above are probably wrong. I wish this was documented in the first place!

For those who want to work with the Orbit objects, you must also take care to swap Y/Z components, but not for all methods (for example, it's already done for vessel.obt_velocity and Orbit.GetRelativeVel ; but you must do it for Orbit.getOrbitalVelocityAtUT).

Thanks everyone for the help sorting it out.

Hmm... and if someone knows how to check what reference frame is used without resorting to hacks such as testing vessel altitude (don't know if the 100km threshold applies to others bodies) that would help too.

Link to comment
Share on other sites

Dammit, I'll never get it right... Things do not match yet.

If I display the vessel velocity, computed from its position in inertial frame, it doesn't match when I'm below 100km. It should be around 2250m/s (circular orbit at 100km), but I get 2040m/s (the difference matches the rotating frame velocity, 210m/s at 100km).

To compute my "true orbital velocity", I use positions and universal time. To compute the positions, I use GetWorldPos3D() - body.position. I don't see how this could be more independent from Kerbin rotation.

So I'm back to what I said in the OP: apparently, the vessel doesn't move at the right velocity when under 100km. While KSP tells me the ship has an orbital speed of 2250m/s (which should be the right value), the vessel is actually moving at 2040m/s.

Link to comment
Share on other sites

There was an anomaly someone reported in an endurance flight challenge recently - the F3 screen was reporting nearly twice the distance covered that a manual calculation would suggest ( and also given we know the planet's circumference ), and the user in question managed to reduce the issue somewhat by adding some resource intensive mods. Try loading up your game a bit & see if your error is the same?

Link to comment
Share on other sites

I found the culprit : vessel.GetWorldPos3D does NOT return the world position (i.e. relative to the sun). It does so only when above 100km. When under 100km, it seems to add a rotation-frame position with the body position (which doesn't make any sense AFAICT).

Also, I found how to know wether the game is in this "rotating frame reference" state or not: one can test the boolean "inverseRotation" of the current body, which is set to true only when the altitude of the current vessel is below mainBody.inverseRotThresholdAltitude

When in this mode, another side effect is that the body transform is frozen (so the body doesn't rotate anymore). Instead, the universe rotates around the body in opposite direction?

The whole thing seems to be another hack similar to the Krakensbane to avoid glitches near a body surface (I guess).

EDIT: actually, vessel.GetWorldPos3D makes sense, as the position is valid relatively to all other objects (I hope). But since the universe is rotating around the body, it can't be used to derive a velocity (you end up with either a rotating-frame velocity, or an absolute velocity, depending on body.inverseRotation value).

Edited by Youen
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...