Jump to content

How to get pitch & roll?


zero_z77

Recommended Posts

So i'm working on a gauge mod and one of the gauges i'm having trouble with is the artificial horizon. I can't seem to figure out how to extract the craft's pitch and roll angles(relative to the planet) from KSP. And to make matters more complicated, i also would like to account for the ship having an unconventional control point, so that if the player changes their control point it will be reflected on the gauge. The main problem i'm having is figuring out which variables to use, i can't seem to find any good documentation on the subject.

So the problem comes in 3 parts:

1. Establishing a surface frame of reference - i'm assuming i can get a good surface reference by using FlightGlobals.ActiveVessel.east and FlightGlobals.ActiveVessel.north and using the cross product or FlightGlobals.ActiveVessel.upAxis for the up vector. That should give me a coordinates system i can use to compute the angles i need. Assuming that those vectors are in a global frame of reference.

2. Getting a transform for the ship. I have several transforms available on FlightGlobals.ActiveVessel and i simply need to know which one is in the same frame of reference as the vectors from part 1. is it Vessel.transform, vessel.GetTransform(), vessel.ReferenceTransform, or vessel.vesselTransform?

3. Accounting for the control point. I'm guessing that FlightGlobals.ActiveVessel.ReferenceTransform gives me a transform for the ship's current control point(relative to the ship's transform?), so i should just be able to apply this to the transform in part 2 in order to get the forward, right, and up vectors needed to compute the pitch & roll against the frame of reference from part 1.

If worst comes to worse, i can just hack the actual navball and use that to get what i need, but i'd like a better solution.

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