SIMatrix4

Object Hierarchy | 関連する C++クラス:CMatrix4

説明

倍精度浮動小数点の4×4行列。移動値は m12、m13、m14、m15に存在します。

| m0 m1 m2 m3 |

| m4 m5 m6 m7 |

| m8 m9 m10 m11 |

| m12 m13 m14 m15 |

メソッド

Get Get2 Invert InvertInPlace
Mul MulInPlace Set SetIdentity
Transpose TransposeInPlace TransposeInverse TransposeInverseInPlace

プロパティ

Value      
       

1. JScript の例

/*
        Demonstration of the Matrix4 object used to 
        print the contents of a Transformation
*/
var oNull = ActiveSceneRoot.AddNull() ;
var oSITransformation = oNull.Kinematics.Local.Transform ;
Application.LogMessage( "Default Transformation Matrix" ) ;
PrintTransformationAsMatrix( oSITransformation ) ; 
oSITransformation.SetTranslationFromValues( 5, 6, 7) ;
oSITransformation.SetScalingFromValues( 1, 4, 1) ;
Application.LogMessage( "Transformation with scaling and translation" ) ;
PrintTransformationAsMatrix( oSITransformation ) ; 
function PrintTransformationAsMatrix( in_Transform )
{
        var oMatrix4 = XSIMath.CreateMatrix4(); 
        oSITransformation.GetMatrix4(oMatrix4) ;
        for ( var row = 0 ; row < 4 ; row++ )
        {       
                strLine = "" ;
                for( var col = 0 ; col < 4 ; col++ )
                {
                        strLine += oMatrix4.Value( row, col ) + "\t\t";
                }
                Application.LogMessage( strLine ) ;
        }
}
//Output:
//INFO : Default Transformation Matrix
//INFO : 1              0               0               0               
//INFO : 0              1               0               0               
//INFO : 0              0               1               0               
//INFO : 0              0               0               1               
//INFO : Transformation with scaling and translation
//INFO : 1              0               0               0               
//INFO : 0              4               0               0               
//INFO : 0              0               1               0               
//INFO : 5              6               7               1

2. VBScript の例

'
' This illustrates how to convert a position from local coordinates
' to global coordinates
'
set oRoot = Application.ActiveProject.ActiveScene.Root
if Selection.Count = 0 then
        ' create a sample scene
        set oModel = oRoot.AddModel
        oModel.posx.value = 5
        set oObject = oModel.AddNull
        oObject.posx.value = 5
else
        set oObject = Selection(0)
end if
'
' Create transformation matrix4 from global transform
'
set oGlobalParameters = oObject.kinematics.global.parameters
Set globalScl = XSIMath.CreateVector3
call globalScl.Set( _
        oGlobalParameters("sclx").value, _
        oGlobalParameters("scly").value, _
        oGlobalParameters("sclz").value )
Set globalRot = XSIMath.CreateVector3
call globalRot.Set( _
        oGlobalParameters("rotx").value, _
        oGlobalParameters("roty").value, _
        oGlobalParameters("rotz").value )
Set globalTrs = XSIMath.CreateVector3
call globalTrs.Set( _
        oGlobalParameters("posx").value, _
        oGlobalParameters("posy").value, _
        oGlobalParameters("posz").value )
set m4Global = CreateMatrix4(globalScl,globalRot,globalTrs)
'
' get local position
'
Set v3Pos = XSIMath.CreateVector3
call v3Pos.Set( oObject.posx.value, oObject.posy.value, oObject.posz.value )
Application.LogMessage "local position = " & v3Pos.x & ", " & v3Pos.y & ", " & v3Pos.z
'
' transform local to global position
'
Set v3Pos = XSIMath.CreateVector3
call v3Pos.MulByMatrix4( v3Pos, m4Global )
Application.LogMessage "global position = " & v3Pos.x & ", " & v3Pos.y & ", " & v3Pos.z
'
' Create and initialize SIMatrix4 using from the scaling, rotation and
' translation values (SIVector3)
'
Function CreateMatrix4( inv3Scl, inv3Rot, inv3Pos )
        Dim l_Rot, l_Trs, l_Matrix, l_RadToDeg, l_DegToRad
        Set l_Rot = XSIMath.CreateVector3
        Set l_Trs = XSIMath.CreateTransform
        Set l_Matrix = XSIMath.CreateMatrix4
        l_RadToDeg = 180.0 / 3.1415926535897932
        l_DegToRad = 3.1415926535897932 / 180.0
        'Conversion of the rotation angles into radians
        l_Rot.Copy inv3Rot
        l_Rot.ScaleInPlace l_DegToRad
        'Create an SI Transform first.
        l_Trs.SetScaling inv3Scl
        l_Trs.SetTranslation inv3Pos
        l_Trs.SetRotationFromXYZAngles l_Rot
        'Extract a Matrix from that transform.
        l_Trs.GetMatrix4 l_Matrix
        Set CreateMatrix4 = l_Matrix
End Function

関連項目

SIMatrix4.Set SIVector3 SIMatrix3 SIMatrix4 SIRotation SITransformation.GetMatrix4 SIQuaternion