SIMatrix3.1.js Example

Applies To

SIMatrix3 object

Description

This example demonstrates how to use the SIMatrix3 object.

Code

var oRoot = Application.ActiveProject.ActiveScene.Root
// Create two cubes, first is the original and second is rotated
var oCube = oRoot.AddGeometry("Cube","MeshSurface", "Cube")	
var oCube2 = oRoot.AddGeometry("Cube","MeshSurface", "Cube2")	
var oTrans2 = oCube2.Kinematics.Local.Transform
var oMat3 = XSIMath.CreateMatrix3()
oTrans2.GetRotationMatrix3 ( oMat3 );
// Modify the matrix to rotate around z
oMat3.value(0,0) = Math.cos (45);
oMat3.value(0,1) = -Math.sin (45);
oMat3.value(1,1) = Math.cos (45);
oMat3.value(1,0) = Math.sin (45);
oTrans2.SetRotationFromMatrix3 ( oMat3 );	
oCube2.Kinematics.Local.Transform = oTrans2;
var vbArr = new VBArray( oMat3.Get2() );
var array = vbArr.toArray();
Application.LogMessage( "SIMatrix3 after the rotation" +
	" 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] );
// Expected results:
//INFO : SIMatrix3 after the rotation 
//		m00:0.5253219888177297	m01:-0.8509035245341184 m02:0 
//		m10:0.8509035245341184	m11:0.5253219888177297	m12:0 
//		m20:0                   m21:0                   m22:1

Keywords

SIMatrix3 Get Get2 GetQuaternion Invert InvertInPlace Mul MulInPlace Set SetFromQuaternion SetIdentity Transpose TransposeInPlace TransposeInverse TransposeInverseInPlace Value


Autodesk Softimage 2011