SIMatrix3.SetFromQuaternion
 
 
 

SIMatrix3.SetFromQuaternion

Introduced

v3.5

Description

Sets the matrix3 using a rotation quaternion.

C# Syntax

SIMatrix3.SetFromQuaternion( SIQuaternion out_pVal );

Scripting Syntax

SIMatrix3.SetFromQuaternion( q );

Parameters

Parameter Type Description
q SIQuaternion The rotation quaternion containing the new matrix3 values.

Examples

VBScript Example

'
' 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

See Also

SIMatrix3.GetQuaternion