NewScene (null, false);
var oRoot = Application.ActiveProject.ActiveScene.Root
// Create two cubes, the first one is rotated by 45 degrees and second
// is the transpose inverse of the first one="SIMatrix4.TransposeInverseInPlace
var oCube = oRoot.AddGeometry("Cube","MeshSurface", "CubeParent")
var oCube2 = oRoot.AddGeometry("Cube","MeshSurface", "CubeParent")
var oTrans = oCube.Kinematics.Local.Transform
var oTrans2 = oCube2.Kinematics.Local.Transform
var oMat3 = XSIMath.CreateMatrix3()
oTrans2.GetRotationMatrix3 ( oMat3 );
// Modify the matrix to scale and rotate around z
oMat3.value(0,0) = 2 * Math.cos (45);
oMat3.value(0,1) = -2 * Math.sin (45);
oMat3.value(1,1) = 2 * Math.cos (45);
oMat3.value(1,0) = 2 * Math.sin (45);
oTrans.SetRotationFromMatrix3 ( oMat3 );
oCube.Kinematics.Local.Transform = oTrans;
var vbArr = new VBArray( oMat3.Get2() );
var array = vbArr.toArray();
Application.LogMessage( "SIMatrix3 before transpose " +
" m00:" + array[0] + " m01:" + array[1] + " m02:" + array[2] +
" m10:" + array[3] + " m11:" + array[4] + " m12:" + array[5] +
" m20:" + array[6] + " m21:" + array[7] + " m22:" + array[8] );
var oMat3Trans = XSIMath.CreateMatrix3()
oMat3Trans.TransposeInverse(oMat3)
oTrans2.SetRotationFromMatrix3 ( oMat3Trans );
var vbArr = new VBArray( oMat3Trans.Get2() );
var array = vbArr.toArray();
Application.LogMessage( "SIMatrix3 after transpose " +
" m00:" + array[0] + " m01:" + array[1] + " m02:" + array[2] +
" m10:" + array[3] + " m11:" + array[4] + " m12:" + array[5] +
" m20:" + array[6] + " m21:" + array[7] + " m22:" + array[8] );
oCube2.Kinematics.Local.Transform = oTrans2;
// Expected results:
//INFO : SIMatrix3 before transpose
// m00:1.0506439776354594 m01:-1.7018070490682368 m02:0
// m10:1.7018070490682368 m11:1.0506439776354594 m12:0
// m20:0 m21:0 m22:1
//INFO : SIMatrix3 after transpose
// m00:0.26266099440886486 m01:-0.4254517622670592 m02:0
// m10:0.4254517622670592 m11:0.26266099440886486 m12:0
// m20:0 m21:0 m22:1 |