Multiplying two matrices
together is more complicated than addition,
subtraction or scalar multiplication. When
matrices are multiplied together each element
must be multiplied by a specific series of
elements in the other matrix then these series
are added together to create a single element
in the resulting matrix. Each element is made
from the a slightly different series creating
a matrix of results.
The pattern of multiplication and addition that this creates is very specific
and creates a characteristic result. This makes matrix multiplication stand out
from the multiplication of other familiar entities as scalars and vectors.
To multiply matrix A by matrix B each element must be treated differently according
to a set pattern. To find the first element of the resulting matrix C, C00 each
element in the first row of matrix A must be multiplied by an element in the
first column of the matrix B in order. The total of each of these products is
then found giving the value of the first element in the resulting matrix C.
For example:
- The first element
in the first row of matrix
A is multiplied by the first element
in the first column of B (A00xB00).
- Then the second element
in the first row of A is multiplied
by the second element in the first column of
B (A01xB10).
- The third and
final element of the first row of
A is multiplied by the third element
in the first column of B (A02xB20).
- The sum of these products
is calculated to give the first element of
the of matrix C (C00 = (A00xB00)+(A01xB10)+(A02xB20)).
This pattern continues for
the next element C01:
- The first element
of the first row of A is multiplied
by the first element of the second column of
B (A00B01),
- The second element
of the first row of A is multiplied
by the second element of the second column of
B,
- The third and last
element in the first row of
A is multiplied by the third element
in the second column of B
(A02xB21),
- The sum of
the product is then calculated (C01 = (A00xB01)+(A01xB11)+(A02xB21)).
The pattern continues
for C10 (C10 = (A10xB00)+(A11xB10)+(A12xB20))
and C11 (C11 = (A10xB01)+(A11xB11)+(A12xB21)).
Matrix A multiplied
by Matrix B:

Numerical example:
It may not be obvious
at first but on closer inspection you can see
that these rules require the number
of Columns of matrix A must equal the number
of Rows in matrix B so that
the resulting matrix is determinable. This
means only certain matrices with the correct
dimensions can be multiplied together if we
want to find a result.
For example:

Because there is no element in matrix B to multiply
with A02 or A12 the resulting sum for every element in C is always incomplete
making the values and the resulting matrix itself nonsense and therefore
indeterminate.
Assuming the basic condition that the number of
columns is equal to the number of rows in the second matrix, matrices have
been shown to exhibit many interesting properties. With classical numbers are
multiplied by 1 the number stays the same. A similar property is also shown by
matrices.
The Unit Matrix

When a matrix is multiplied by a matrix called the "unit
matrix" it remains unchanged.

The zeros in each column cancel out the other terms in each of the elements of
the resulting matrix. The unit matrix can be modified to change the resulting
matrix in predictable ways as each non zero term in the unit matrix acts on a
single specific column of elements in the matrix it is multiplied with. This
can be very usefull if you wish to perform a transformation on the data in a
matrix for example if you create a matrix with the x,y,z coordinates of a 3d
point and you multiply it with this modified unit matrix:

The resulting matrix is identical accept for the fact that the x coordinate is
now negative.

This has the effect of reflecting that point on the y axis. Modifying
other values in the unit matrix can create reflection about other axis:
Matrices that perform a specific task on a set of coordinates
are called matrix operators. There are a variety of matrix operators which are
designed specifically to act on a set of coordinates reflection, translation, rotation and distortion.
Each one uses the properties of matrix multiplication to function. Although operations
such as these can be accomplished using basic algebraic techniques matrix manipulation
is often used when dealing with large sets of coordinates as is simplifies
and organizes the calculations involved.
Matrix Multiplication Function
Using A 1D Array In Actionscript (4 2d points)
first_matrix = new Array (20,150,
80,60, 95,130, 220,110);
second_matrix = new Array (2,5,0,3);
matrix_mult (my_point_matrix, y_trans_matrix);
fucntion = matrix_mult (matrixA:Array, martrixB:Array):Array {
var result_matrix:Array = new Array();
result_matrix[0] = matrixA[0]*martrixB[0] + matrixA[1]*martrixB[2];
result_matrix[1] = matrixA[0]*martrixB[1] + matrixA[1]*martrixB[3];
result_matrix[2] = matrixA[2]*martrixB[0] + matrixA[3]*martrixB[2];
result_matrix[3] = matrixA[2]*martrixB[1] + matrixA[3]*martrixB[3];
result_matrix[4] = matrixA[4]*martrixB[0] + matrixA[5]*martrixB[2];
result_matrix[5] = matrixA[4]*martrixB[1] + matrixA[5]*martrixB[3];
result_matrix[6] = matrixA[6]*martrixB[0] + matrixA[7]*martrixB[2];
result_matrix[7] = matrixA[6]*martrixB[1] + matrixA[7]*martrixB[3];
return result_matrix;
}
Matrix Multiplication Function
Using A 2 Dimentional Array In Actionscript (4
2d points)
var first_matrix:Array = new Array ();
first_matrix [0][0] = 20;
first_matrix [0][1] = 150;
first_matrix [1][0] = 80;
first_matrix [1][1] = 60;
first_matrix [2][0] = 95;
first_matrix [2][1] = 130;
first_matrix [3][0] = 220;
first_matrix [3][1] = 110;
var second_matrix = new Array ();
second_matrix = [0][0]= 2;
second_matrix = [0][1]= 5;
second_matrix = [1][0]= 0;
second_matrix = [1][1]= 3;
matrix_Multiply(first_matrix:Array, second_matrix:Array)
function = matrix_Multiply(A:Array,B:Array)
{
var C = new Array(new
Array(), new Array());
C[0][0]
= A[0][0]*B[0][0]+A[0][1]*B[1][0];
C[0][1]
= A[0][0]*B[0][1]+A[0][1]*B[1][1];
C[1][0]
= A[1][0]*B[0][0]+A[1][1]*B[1][0];
C[1][1]
= A[1][0]*B[0][1]+A[1][1]*B[1][1];
C[2][0]
= A[2][0]*B[0][0]+A[2][1]*B[1][0];
C[2][1]
= A[2][0]*B[0][1]+A[2][1]*B[1][1];
return
C;
}
Matrix Multiplication Function
Using A 2D Array In Actionscript (4 3d
points)
var first_matrix:Array = new
Array ();
first_matrix [0][0] = 20;
first_matrix [0][1] = 150;
first_matrix [0][0] = 80;
first_matrix [1][0] = 60;
first_matrix [1][1] = 95;
first_matrix [1][2] = 130;
first_matrix [2][0] = 220;
first_matrix [2][1] = 110;
first_matrix [2][2] = 20;
first_matrix [3][0] = 280;
first_matrix [3][1] = 160;
first_matrix [3][2] = 90;
var second_matrix = new Array ();
second_matrix = [0][0]= 2;
second_matrix = [0][1]= 5;
second_matrix = [0][2]= 0;
second_matrix = [1][0]= 3;
second_matrix = [1][1]= 2;
second_matrix = [1][2]= 5;
second_matrix = [2][0]= 8;
second_matrix = [2][1]= 1;
second_matrix = [2][2]= 3;
matrix_Multiply(first_matrix:Array, second_matrix:Array)
function = matrix_Multiply(A:Array,B:Array) {
var C = new Array(new Array(), new Array(), new
Array());
C[0][0] = A[0][0]*B[0][0]+A[0][1]*B[1][0]+A[0][2]*B[2][0];
C[0][1] = A[0][0]*B[0][1]+A[0][1]*B[1][1]+A[0][2]*B[2][1];
C[0][2] = A[0][0]*B[0][2]+A[0][1]*B[1][2]+A[0][2]*B[2][2];
C[1][0] = A[1][0]*B[0][0]+A[1][1]*B[1][0]+A[1][2]*B[2][0];
C[1][1] = A[1][0]*B[0][1]+A[1][1]*B[1][1]+A[1][2]*B[2][1];
C[1][2] = A[1][0]*B[0][2]+A[1][1]*B[1][2]+A[1][2]*B[2][2];
C[2][0] = A[2][0]*B[0][0]+A[2][1]*B[1][0]+A[2][2]*B[2][0];
C[2][1] = A[2][0]*B[0][1]+A[2][1]*B[1][1]+A[2][2]*B[2][1];
C[2][2] = A[2][0]*B[0][2]+A[2][1]*B[1][2]+A[2][2]*B[2][2];
C[3][0] = A[3][0]*B[0][0]+A[3][1]*B[1][0]+A[3][2]*B[2][0];
C[3][1] = A[3][0]*B[0][1]+A[3][1]*B[1][1]+A[3][2]*B[2][1];
C[2][2] = A[3][0]*B[0][2]+A[3][1]*B[1][2]+A[3][2]*B[2][2];
return C;
}
To learn more
about matrices in flash see:
[Matrix
Knowledgebase]
[Adding Matrices]
[Subtracting
Matrices]
[Multiplying
A Matrix By A Scalar]