E
ex-orbinaut
Guest
Perhaps someone has a sound grip on this. I will reduce the blurb to a minimum.
OBJECTIVE: Function to immediately rotate a vessel to 0º bank and 0º pitch relative to the reference body, using SetGlobalOrientation(). It is also important that the heading (on the reference body) not be changed in the process.
Present development...
So far, so good. As a point of note, it is also possible to obtain these euler angles by doing the conversion of the Matrix, as the Doctor says in his API Reference Manual. However, going into that will just bulk out the text of what has already been accomplished above. You get what I mean, anyway.
The snag comes when I try to set the pitch to 0º. There seems to be a confusing feature of SetGlobalOrientation() here. The angle around the x axis CANNOT be used to do the same with GetPitch(), even if it is done in two steps (bank first, then pitch).
So, what's confusing?
The SetGlobalOrientation() around the z axis appears to be equivalent to the local vessel frame, and not the global.
Done my head in... I am obviously misunderstanding something.
Can somebody please be so kind as to point me in the right direction to set that pitch to 0º, as the Rotation functions in the OrbiterAPI are a veritable labyrinth that frequently lead to the same outcome and REALLY do succeed in losing one completely.
That, of course, unless trying previously has not done the same thing to you...
If any assistance is forthcoming it will be duly appreciated. My thanks in advance.
OBJECTIVE: Function to immediately rotate a vessel to 0º bank and 0º pitch relative to the reference body, using SetGlobalOrientation(). It is also important that the heading (on the reference body) not be changed in the process.
Present development...
Code:
VECTOR3 HorInvRot;
HorizonInvRot(_V(0, 1, 0), HorInvRot);
double bankdif = atan2(HorInvRot.x, HorInvRot.y);
// is the same as...
double bank = GetBank();
// so now then...
VECTOR3 Glob_Orient;
GetGlobalOrientation(Glob_Orient);
// ...gives you the same as...
VESSELSTATUS vs;
GetStatus(vs);
// vs.arot.x, vs.arot.y, vs.arot.z
// ...and with this it is easy enough to set a 0º bank angle by doing...
Glob_Orient.z += bank;
// ...or, indeed, "vs.arot.z += bankdif"...
// ...and this physically sets the bank to 0º relative to the surface of the reference body...
SetGlobalOrientation(_V(Glob_Orient.x, Glob_Orient.y, Glob_Orient.z));
The snag comes when I try to set the pitch to 0º. There seems to be a confusing feature of SetGlobalOrientation() here. The angle around the x axis CANNOT be used to do the same with GetPitch(), even if it is done in two steps (bank first, then pitch).
So, what's confusing?
The SetGlobalOrientation() around the z axis appears to be equivalent to the local vessel frame, and not the global.
Done my head in... I am obviously misunderstanding something.
Can somebody please be so kind as to point me in the right direction to set that pitch to 0º, as the Rotation functions in the OrbiterAPI are a veritable labyrinth that frequently lead to the same outcome and REALLY do succeed in losing one completely.
That, of course, unless trying previously has not done the same thing to you...
If any assistance is forthcoming it will be duly appreciated. My thanks in advance.