SIMatrix3.GetQuaternion

SIMatrix3.GetQuaternion

導入

v3.5

詳細

matrix3の回転のクォータニオン表現を戻します。

C#構文

SIMatrix3.GetQuaternion( SIQuaternion out_pVal );

スクリプト構文

SIMatrix3.GetQuaternion( q );

パラメータ

パラメータ タイプ 説明
q SIQuaternion 新しい 3x3 行列の値を含む、回転のクォータニオン

JScript の例

/*

	This example illustrates how to get the orientation of 

	one object relative to another.

*/

// CREATE OBJECTS A & B

var A = ActiveSceneRoot.AddNull("A");

var B = ActiveSceneRoot.AddNull("B");

// GET GLOBAL TRANSFORM OF A & B

var gksA = A.Kinematics.Global; 

var gksB = B.Kinematics.Global; 

var tgA = gksA.Transform;

var tgB = gksB.Transform;

// TRANSLATE & ROTATE A

var vA = XSIMath.CreateVector3(2, 2, 0);

tgA.SetTranslation(vA);

var rA = XSIMath.CreateRotation( 0, 0, XSIMath.DegreesToRadians(45) ); 

tgA.SetRotation(rA);

gksA.Transform = tgA;

// GET LOCAL TRANSFORM OF B RELATIVE TO A

var mA = XSIMath.CreateMatrix3();

var mB = XSIMath.CreateMatrix3();

tgA.GetRotationMatrix3(mA);

tgB.GetRotationMatrix3(mB);

mA.TransposeInPlace();

mB.MulInPlace(mA);

// GET ORIENTATION OF B RELATIVE TO A AS A QUATERNION

var qB = XSIMath.CreateQuaternion();

mB.GetQuaternion(qB);

// LOG RESULT

Application.LogMessage("Q(" + qB.w + "," + qB.x + "," + qB.y + "," + qB.z);	

// Verify result by creating a child on A and transform it to

// have the same orientation as B

var oChild = A.AddNull("Child");

var lksChild = oChild.Kinematics.Local;

var tlChild = XSIMath.CreateTransform();

tlChild.SetRotationFromQuaternion(qB);

lksChild.Transform = tlChild;

// Expected results:

// INFO : Q(0.9238795325112867,0,0,-0.3826834323650898

関連項目

SIMatrix3.SetFromQuaternion