Jump to content

Get vessel position in PQS coordinates


mic_e

Recommended Posts

Hi,

what methods and transformations are required to calculate the vessel position in PQS coordinates (those that are accepted by the pqsController.RayIntersection method)?

What if I am looking for the position at some point (in seconds) in the future?

Unfortunately, the best 'documentation' I seem to find on this topic are the method names in the Vessel/CelestialBody/PQS APIs...

Link to comment
Share on other sites

Given the message signature is:

public bool RayIntersection(Vector3 worldStart, Vector3 worldDirection, out Vector3d intersection)

I'd imagine it's in worldspace co-ordinates, so it's simply vessel.transform.position (or .position of whatever transform you want to use to represent the vessel).

The future generally is obviously not predictable as it depends on user control inputs, so you have a specific circumstance in mind?

Link to comment
Share on other sites

Thank you for your reply!

The future generally is obviously not predictable as it depends on user control inputs, so you have a specific circumstance in mind?

I'm talking about the future where the vessel simply follows its normal orbit (no atmospheric or engine acceleration). One of the main problems I'm seeing here is that the body will of course rotate, so I assume I'd require additional transformations...

Link to comment
Share on other sites

One of the main problems I'm seeing here is that the body will of course rotate, so I assume I'd require additional transformations...

I'm not familiar with how the orbits are given. If they do give out a vector relative to the planet then planet.transform.TransformPoint(orbitPosition) will convert it to a world space vector. I wouldn't be surprised if they gave out the position in world space directly though.

EDIT: Where planet should be the relevent object of type CelestialBody

Link to comment
Share on other sites

So, world space is the camera coordinate system, right?

I failed to mention in my original post that I already DO have code to determine longitude, latitude and altitude for a specific timepoint, which might simplify the problem a lot.

So a way to convert from long/lat/alt to a PQS vector would be OK, too...

Currently, I'm having the impression that the PQS system (= world system?) does not rotate with the result of the Ray casting method would vary with the time when it is called...

Link to comment
Share on other sites

World space is the top level co-ordinate system, it's sort of used in unity as the common reference when it would be too tiresome to translate up and down manually. Every transform has built in methods ((Inverse)TransformPoint/Direction) to translate to and from it.

The PQS classes are Components (Monobehaviours) that are attached to the GameObject representing a planet (or a child) and seem to handle the terrain and features of that planet. There are various other components that go to make up 'the planet' like CelestialBody and OrbitDriver. I don't actually know how the rotation is handled though, whether the planetary GameObject is rotated or whether the information is stored in one of the components. Although the former seems at first glance as if it would be much simpler I haven't actually checked the object to see whether it's rotation values change over time.

The planetary GameObjects are named after their planet, Kerbin, Eeloo, The Sun etc. or you can just grab the object that a handy relevant component is attached to (e.g. CelestialBody). Last time I checked there were actually two objects for each planet with the same name, a parent and child, but I don't know what that's about (it may even just had been a bug in my code).

Link to comment
Share on other sites

You can get worldspace from your lat/long/alt. I think it's GetWorldSpacePosition or something like that. Planetary rotation is computed by that function based on the celestial body's directRotation (the directRot angle is applied as a rotation to the worldspace vector which the latitude and longitude, unrotated, yield, I presume).

It's very annoying, really, that's exactly what prevents axial tilt from working. :\

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