Jump to content

Get ground projection coordinates


Recommended Posts

Allright Ladies and Gentlemen,

I have an issue regarding surface and world space coordinates.

For predicting my touchdown coordinates I need my current orbital position in the same reference frame.

If you don't know what I mean, ask KerbalEngineer for your longitude and lattitude while in high orbit.

Vessel.longitude gives you the value in the non-rotating reference frame and not the surface position you are currently flying over.

Methods like CelestialBody.GetWorldSurfacePosition(System.Double,System.Double,System.Double) usually give the world coordinates for surface coordinates, not the other way round.

I may find a way to calculate impact point in world coordinates, but that is more complicated in my view.

TL;DR: How do I find out over which ground coordinate I am currently flying in high orbit?

Update:

I hope you don't mind my thinking loud.

What if I monitor the spacecraft's ascent from the surface until FlightGlobals.RefFrameIsRotating becomes false.

The last coordinate in rotating frame, the first coordinate in non-rotating frame and the universal time of the transition are stored.

Then, knowing Kerbin (or any other body) rotates 360° in 21600 seconds, I can calculate the angular difference between rotating and non-rotating frame for any given universal time, for example just right now. Do you think that might work?

Thanks

cm2227

Edited by cm2227
Update
Link to comment
Share on other sites

I can't help in term of where you can get the data, I am interrested in it however.

If KerbalEngineer get the data you are looking for, have a look at their code, and if it's how it works, ask the dev if you can use this part of the code.

Link to comment
Share on other sites

If KerbalEngineer get the data you are looking for, have a look at their code, and if it's how it works, ask the dev if you can use this part of the code.

KerbalEngineer does the same as my plug-in right now: It reads the longitude from vessel.longitude, which is (while in non-rotating reference frame) not the surface longitude.

So this doesn't really help.

Next thing is: I don't want to reverse-engineer or copy other mods, I want to broaden my knowledge of orbit mechanics and KSP by writing it myself.

Link to comment
Share on other sites

I'm not on my development computer at the moment so I can't check, but there are methods in KSP for converting between reference frames.

Looking at the API docs, do the following help?

<member name="P:FlightGlobals.RefFrameIsRotating">

<summary>

Whether KSP is doing its computations in an inertial reference frame, or the reference frame that

rotates with the current dominant celestial body.

</summary>

</member>

<member name="M:CelestialBody.GetSurfaceNVector(System.Double,System.Double)">

<summary>

Returns a unit vector perpendicular to the surface of the body at the given latitude and

longitude (pretending for the moment that the body is a perfect sphere).

</summary>

<param name="lat">Latitude in degrees</param>

<param name="lon">Longitude in degrees</param>

<returns>A unit normal vector to the surface</returns>

</member>

<member name="M:CelestialBody.GetWorldSurfacePosition(System.Double,System.Double,System.Double)">

<summary>

Returns the position, in world coordinates, of a given latitude, longitude, and altitude

</summary>

<param name="lat">Latitude in degrees</param>

<param name="lon">Longitude in degrees</param>

<param name="alt">Altitude above sea level in meters</param>

<returns>Position in world coordinates</returns>

</member>

I have seen methods for converting to/from the world frame also, but my search skills are failing at the moment.

The other thing is you would probably require a Krakensbane check to make sure that is not interjecting more variables into the equation.

Hopefully that works as a point to start.

D.

Link to comment
Share on other sites

Hey Diazo,

thanks for the advice. I know of these API calls, but I don't know about injecting more variables into the equation. If I do that simple correction for the angular difference between rotating and non-rotating frame, how can any more variables become part of my (or KSPs) equations?

I must admit, I havent't implemented that feature yet. I still battle my iterator calculating bull***** while it worked flawless in C++ code.

Edit:

I now understand the problem. Once the iterative solver has started, it must not refer to any values from the game that might have changed since starting the iteration. I have to re-check my code for these references and see which errors persist.

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