Jump to content

Guide to different reference frames?


Recommended Posts

Is there a guide anywhere to what reference frames are used to compute various positions, velocities and transforms?  For example:

FlightGlobals.ActiveVessel.orbit: pos and vel are relative to the center of the reference body, but seem to rotate along with it, although they're an inertial frame.  

FlightGlobals.ActiveVessel.GetTransform(): The position is (0, 0, 0) on the launch pad, then increases as you lift off, which makes me think the origin is on the launch pad ... until you clear the tower, when it goes to zero.  And it seems to rotate along with Kerbin.  Is there a description of the transform hierarchy somewhere?  What's the parent of the active vessel?

 

Link to comment
Share on other sites

This is actually quite a mess due to several workarounds Squad has implemented so that KSP can even run. The reference frames I am aware of are:

1) "Real-space", or the current physics bubble. If you are reading Unity documentation this is referred to as World space. Even this has two modes:

1a) Real-space, low speed. At low speeds the physics bubble is centered on the vessel being switched to and extends out in a bubble with a radius of roughly 2.5km and the zero-point stays at this point even as the vessel moves away. Note this is relative, anytime you switch to a low speed vessel the bubble's zero-point is set to the vessel being switched to. This is why when you launch a vessel, the launch pad has the zero point as it is where the vessel spawned. If you have a rover at the north pole, when you switch to it from the Space Center, you will find the origin point is now where the rover was parked.

1b) Real-space, high speed. At high speeds, the real-space physics bubble is simply tied to the current vessel and so the current vessel will always be the zero-point.

The two huge implications this has are: Real-space co-ordinates are fluid and not reliable, you can't use them for anything as they do not save. Second is that any ships not in real-space don't exist, only ships that have been unpacked (there is a message in the log) exist and can be interacted with, all others only exist as ProtoVessels that are much more limited.

2) Part-space. (Called Part-space in the Unity documentation.) Each part has it's own reference frame that can be referred to. This is consistent across saves and can be safely referenced. Note that for most purposes, the Vessel reference frame is the Part-space reference of the root part of the vessel.

3) Scaled-space. This is what you see when you look at the tracking station and what the Orbit class works on (I think?). At this level objects don't exist except as their prototypes (ProtoVessel, etc.) and physics is not enabled. I have not worked here at all so I don't know any more details. Notably I am not sure how to get from this space to real-space coordinates and back.

Hope that gives you a starting point, if anyone else has more details it would be helpful, I've only really worked in Real-space so I'm not clear on the fine details of a lot of this.

D.

Edited by Diazo
Link to comment
Share on other sites

Thanks, that's a helpful starting point.  Maybe your response should be made into a wiki page?  Would be great if people could find it easily after this thread is buried.

And it helps to remember that at low speed KSP is only simulating a small bubble, that explains a lot about the reference frames.  The vessel really is at the center of the Universe. :)

Link to comment
Share on other sites

1 hour ago, Diazo said:

3) Scaled-space. This is what you see when you look at the tracking station and what the Orbit class works on (I think?). At this level objects don't exist except as their prototypes (ProtoVessel, etc.) and physics is not enabled. I have not worked here at all so I don't know any more details. Notably I am not sure how to get from this space to real-space coordinates and back.

No, scaled space is a miniature representation of the whole system. It is the view of the tracking station, map and the flight view of the planets when you are far from them.

The orbit call work in full scale and relative to their mainBody (and you have call that give you position in the whole system, relative to the Sun).

Link to comment
Share on other sites

So that's 4 difference reference frames? Ugh.

World-Space (the physics bubble), Part-space (relative to individual parts), Full Scale system (orbit class), Scaled-Space (tracking station and such).

Rather glad I've never worked with anything but the World-Space and UI now.

D.

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...