option explicit
' CREATE OBJECTS A & B
dim A : set A = ActiveSceneRoot.AddNull("A")
dim B : set B = ActiveSceneRoot.AddNull("B")
' GET GLOBAL TRANSFORM OF A & B
dim gksA : set gksA = A.kinematics.global
dim gksB : set gksB = B.kinematics.global
dim tgA : set tgA = gksA.transform
dim tgB : set tgB = gksB.transform
' TRANSLATE & ROTATE A
dim vA : set vA = XSIMath.CreateVector3(2, 2, 0)
tgA.SetTranslation vA
dim rA : set rA = XSIMath.CreateRotation( 0, 0, XSIMath.DegreesToRadians( 45 ) )
tgA.SetRotation rA
gksA.transform = tgA
' GET LOCAL TRANSFORM OF B RELATIVE TO A
dim mA : set mA = XSIMath.CreateMatrix3
dim mB : set mB = XSIMath.CreateMatrix3
tgA.GetRotationMatrix3 mA
tgB.GetRotationMatrix3 mB
mA.TransposeInPlace()
mB.MulInPlace mA
' GET ORIENTATION OF B RELATIVE TO A AS A QUATERNION
dim qB : set qB = XSIMath.CreateQuaternion
mB.GetQuaternion qB
' log result
dim x,y,z : qB.GetXYZAngleValues x, y, z
Application.LogMessage( "R(" & _
XSIMath.RadiansToDegrees(x) & "," & _
XSIMath.RadiansToDegrees(y) & "," & _
XSIMath.RadiansToDegrees(z) & ")" ) |