I don't speak english fluently
HI !
I would like to know how to obtain the spaceship orientation (pitch, yaw, roll) for display a custom navball on my dashboard. I found this code here but it doesn't works very well (it indicates the same orientation for differents orientations) :
private Quaternion updateHeadingPitchRollField (Vessel v)
{
Vector3d CoM, north, up;
Quaternion rotationSurface;
CoM = v.CoM;
up = (CoM - v.mainBody.position).normalized;
north = Vector3d.Exclude(up, (v.mainBody.position + v.mainBody.transform.up * (float)v.mainBody.Radius) - CoM).normalized;
rotationSurface = Quaternion.LookRotation(north, up);
return Quaternion.Inverse(Quaternion.Euler(90, 0, 0) * Quaternion.Inverse(v.GetTransform().rotation) * rotationSurface);
}
Quaternion attitude = updateHeadingPitchRollField(ActiveVessel);
float pitch = (float) ((attitude.eulerAngles.x > 180) ? (360.0 - attitude.eulerAngles.x) : -attitude.eulerAngles.x);
float yaw = (float) attitude.eulerAngles.y;
float roll = (float) ((attitude.eulerAngles.z > 180) ? (attitude.eulerAngles.z - 360.0) : attitude.eulerAngles.z);
And if it possible, I would like to know also, how to obtain the orientation of the prograde, the normal, the radial-in, the maneuver and the target. I apologies for all these questions but I didn't found a complete documentation on the subject.
Thanks.