API Question Calculating AROT question

ADSWNJ

Scientist
Addon Developer
Joined
Aug 5, 2011
Messages
1,667
Reaction score
3
Points
38
I have an RPOS and RVEL to Earth, for a DefSetStateEx call (using GPOS, GVEL of course). I want the AROT to orient the vehicle along the velocity vector, "right way up".

My thinking: Z-hat comes from normalized RVEL, X-hat comes from cross product of RPOS and RVEL, and Y-hat is then the cross product of Z-hat and X-hat.

From this, determine the three Euler angles to rotate the global coordinate frame to this desired orientation. But when I manually orient to the desired direction, and look at AROT from a GetStateEx, I get a totally different solution.

Has anyone been through this, and can lay out the math first, and then the implementation into Orbiter API?

TIA.
 

martins

Orbiter Founder
Orbiter Founder
Joined
Mar 31, 2008
Messages
2,448
Reaction score
462
Points
83
Website
orbit.medphys.ucl.ac.uk
This should be the coversion between rotation matrix R and the Euler angles stored in arot:

arot -> R:

[math] \begin{array}{ll} sinx = \sin(arot.x) & cosx = \cos(arot.x) \\ siny = \sin(arot.y) & cosy = \cos(arot.y) \\ sinz = \sin(arot.z) & cosz = \cos(arot.z) \end{array} [/math][math] R = \left[ \begin{array}{ccc} cosy cosz & cosy sinz & -siny \\ sinx siny cosz - cosx sinz & sinx siny sinz + cosx cosz & sinx cosy \\ cosx siny cosz + sinx sinz & cosx siny sinz - sinx cosz & cosx cosy \end{array} \right] [/math]
and R -> arot:

[math] arot.x = \tan^{-1} \frac{R_{23}}{R_{33}}\qquad arot.y = -\sin^{-1} R_{13}\qquad arot.z = \tan^{-1}\frac{R_{12}}{R_{11}} [/math]
 

ADSWNJ

Scientist
Addon Developer
Joined
Aug 5, 2011
Messages
1,667
Reaction score
3
Points
38
Thanks Martin - will try this and I'll report back.
 
Top