The identity or "unit"
matrix is a matrix operator which when multiplied
by a matrix it leaves
the original matrix untouched. The elements
of the identity matrix are all zero except
the values along the main diagonal which a
equal to one. For example a 3x3 identity matrix.
When the identity matrix is multiplied by a simple
1x3 matrix (row vecor) only one elment from each
row and column of the identity matrix is non
zero leaving only one term in each element of
the resulting matrix. Because the value of these
elements is equal to oen the resulting product
is unchanged
Note: This
matrix multiplication for a single 2d point can
be simplified to a 1x2 coordinate matrix and a
2x2 identity matrix. However in flash the identity
method modifies the transformation matrix which
is a 3x3 matrix and for the sake of clarity and
consistency I have presented the example of this
coordinate operation using a 3x3 identity matrix
and added an place holder value as the third element
in the 1x3 matrix (row vector) to ensure it has
the correct dimentions.
Method I: Modified Tranformation matrix
import flash.geom.Matrix;
onEnterFrame = function{
my_mc.transform.matrix = new Matrix();
}
Not setting the properties
of the transformation amtrix creates a identity
matrix operator by default.
Method II: Using the identity
matrix transformation "method"
import flash.geom.Matrix;
onEnterFrame = function{
my_matrix = new Matrix()
my_mc.my_matrix.identity();
}
The identity "method"
perfroms and identity operation on the movie
clip leaving its coordinates unchanged.
my_point_matrix = new Array
(20,150, 80,60, 95,130, 220,110);
identity_matrix = new Array (1,0, 0,1);
matrix_mult (my_point_matrix, identity_matrix);
matrix_mult (matrixA:Array, martrixB:Array):Array
{
var result_coords:Array = new Array();
result_coords[0] = matrixA[0]*martrixB[0] + matrixA[1]*martrixB[3];
result_coords[1] = matrixA[0]*martrixB[1] + matrixA[1]*martrixB[4];
result_coords[2] = matrixA[2]*martrixB[0] + matrixA[3]*martrixB[3];
result_coords[3] = matrixA[2]*martrixB[1] + matrixA[3]*martrixB[4];
result_coords[4] = matrixA[4]*martrixB[0] + matrixA[5]*martrixB[3];
result_coords[5] = matrixA[4]*martrixB[1] + matrixA[5]*martrixB[4];
result_coords[6] = matrixA[6]*martrixB[0] + matrixA[7]*martrixB[3];
result_coords[7] = matrixA[6]*martrixB[1] + matrixA[7]*martrixB[4];
return result_coords;
}
To learn more about transforming
matrices in flash see the [Matrix
Transformation Knowledgebase].