Image programming in actionscript3 games)

Source: Internet
Author: User

Total Directory: http://blog.csdn.net/iloveas2014/article/details/38304477

4.3.5 matrix mathematics in dynamicmatrix

Before entering the adjustcolor class, let's first understand a key class used in it-dynamicmatrix, which is also located in FL. in the motion package, you can find the usage instructions for this class in the Adobe help file, and view its source code to understand its implementation process.


Unlike matrix, dynamicmatrix supports a matrix of any number of rows and any number of columns. Run the following code:

 

var mt:DynamicMatrix = new DynamicMatrix(5, 4);



The program will create a matrix of five rows and four columns for you.


We can use the getvalue and setvalue methods to obtain and set the value of an element.


The adjustcolor class contains four attributes: color, brightness, contrast, and saturation. Each attribute has its own transform matrix and needs to be applied to the same colormatrixfilter at the same time, matrix Operations are indispensable.

 

Therefore, in this class, you can find many mathematical operations on the matrix:


Public Function loadidentity (): void

Fill in with the data in the unit matrix. The main diagonal element is set to 1, and other elements are equal to 0.


Public Function loadzeros (): void

Fill with zero matrix data. All elements are equal to 0.

 

Addition operation of the matrix: Public Function add (inmatrix: dynamicmatrix): Boolean

 

Matrix Multiplication: Public Function multiplynumber (value: Number): Boolean

 

Matrix Multiplication: Public Function multiply (inmatrix: dynamicmatrix, order: Int = matrix_order_prepend): Boolean

 

I have provided a detailed explanation of addition, multiplication, multiplication, and other computations. It is not difficult to understand their implementation process in conjunction with the content in section 4.1. Note that when order is equal to matrix_order_prepend, execute this × inmatrix, order is equal to matrix_order_append, and execute inmatrix × this, which is not equivalent because matrix multiplication does not meet the exchange law.

 

I am sorry that dynamicmatrix does not provide an inverse matrix algorithm. However, when I read the linear algebra textbooks, I feel that it is justifiable not to provide the inverse matrix implementation in ActionScript. With the increase of the number of rows and columns of the matrix, the calculation process of the inverse matrix becomes more and more complex. It involves advanced mathematics knowledge such as the deciding factor, the multivariate one-time equation, the Gaussian elimination element, and the matrix replacement, it will be difficult to complete without relying on mathematical programming languages (such as MATLAB and mathemetica. However, it is not a program that specializes in mathematics. If you really want to dig deep in the field, it would be worth a little effort.

 

The above operations are still too common and are not convenient to apply in color transformation. Therefore, Adobe expands a subclass of colormatrix Based on dynamicmatrix, which encapsulates the color matrix operation for adjustcolor to be called directly.

 

 


 

Image programming in actionscript3 games)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.