Back to "flash Basic Theory Class-Catalog"
We are not going to introduce some new methods of motion, physics, or rendering graphics in this chapter. What I'm going to introduce you to is the matrix, which gives us a new alternative.
Matrices are used very frequently in the rotation, scaling, and panning (motion) of 3D points in 3D systems. It is also used in the transformation of various 2D graphics. You may recall that the Begingradientfill method uses matrices to set position, size, and rotation proportions.
In this chapter you will see how to create a 3D matrix system to manipulate 3D videos and see some of the built-in matrices in Flash. I'm glad that there's not a single mention of Keanu Reeves [Keanu-Reeves, especially the Matrix] film. Let's see how long I can hold on.
Matrix Foundation
The simplest definition of a matrix is a numeric table. It can have one or more horizontal rows and one or more vertical columns. Figure 18-1 shows some of the matrices.
Fig. 18-1 A 3x3 matrix, a 1x3 matrix, a 3x1 matrix
Matrices are usually described by variables, such as M. To represent a particular unit in a matrix, we use a variable that usually uses the values of rows and columns as the index of the foot. For example, if the 3x3 matrix in Figure 18-1 is called M, then m2,3 is equal to 6 because it points to the second row, the third column.
A unit of a matrix can contain not only simple numbers, but also formulas and variables. In fact, a spreadsheet is a large matrix. We can save the sum of a column in one cell, multiply it by a fraction in another cell, and so on. We see that such a matrix should be very useful.
Matrix operations
A spreadsheet is like a free combination of matrices, the matrices we're dealing with are more structured, and there are rules for what to do with them and how to generate them.
Most of the matrix math textbooks I have seen are only one of two methods. First, the school is about the details of matrix operations, and the entire matrix used is almost all random numbers. We learn these rules, but we do not know why we should do these things or what the results will represent. It's like playing a game that arranges numbers into beautiful shapes.
The second method is to describe the contents of the matrix in detail but skip the manual operation, such as "multiply the two matrices to get the result ..." and let the reader not know how the multiplication is calculated.
To make sure everyone understands how the matrix works, I choose a method that combines the two (tradeoffs), starting with some numerical matrices, and then describing how to do matrix multiplication.