SIMatrix3.SetFromQuaternion

導入

v3.5

詳細

回転のクォータニオンを使用して3x3行列を設定します。

C#構文

SIMatrix3.SetFromQuaternion( SIQuaternion out_pVal );

スクリプト構文

SIMatrix3.SetFromQuaternion( q );

パラメータ

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

VBScript の例

'

' This example illustrates how to interpolate the pose of object C

' between objects A and B 

'

option explicit

dim alpha : alpha = 0.25

' 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

' TRANSLATE & ROTATE B

dim vB : set vB = XSIMath.CreateVector3(-2, 2, 0)

tgB.SetTranslation vB 		

dim rB : set rB = XSIMath.CreateRotation( 0, 0, XSIMath.DegreesToRadians(-45) )

tgB.SetRotation rB 

gksB.Transform = tgB

' GET ROTATION MATRIX OF A & B

dim mA : set mA = XSIMath.CreateMatrix3

tgA.GetRotationMatrix3 mA

dim mB : set mB = XSIMath.CreateMatrix3

tgB.GetRotationMatrix3 mB

' DO A SLERP BETWEEN THE ROTATION MATRICES

dim qA : set qA = XSIMath.CreateQuaternion

mA.GetQuaternion qA

dim qB : set qB = XSIMath.CreateQuaternion

mB.GetQuaternion qB

dim qC : set qC = XSIMath.CreateQuaternion

qC.Slerp qA, qB, alpha 

' DO A LINEAR INTERPOLATE OF POSITION

dim vC : set vC = XSIMath.CreateVector3

vC.LinearlyInterpolate vA, vB, alpha

' CREATE A NEW OBJECT AND SET ITS ROTATION 

' AND TRANSLATE WITH INTERPOLATED RESULTS

dim C : set C = ActiveSceneRoot.AddNull("C")

dim gksC : set gksC = C.Kinematics.Global 

dim tgC : set tgC = gksC.Transform

dim mC : set mC = XSIMath.CreateMatrix3

mC.SetFromQuaternion qC

tgC.SetRotationFromMatrix3 mC

tgC.SetTranslation vC

gksC.Transform = tgC

関連項目

SIMatrix3.GetQuaternion