Transform matrix in Flex & flash (transformation matrix)

Source: Internet
Author: User
Tags in degrees

"Transformation matrix" uses "affine transformations affine transformation" properties:

The "affinine transform" refers to the coordinate point that changes the relative distance in the space while the coordinate points are in the same line (surface. This means that the plane of the coordinate point does not change, and the original parallel straight line is still parallel, but the distance between the coordinate point and the coordinate point may change proportionally to the original. The "affinsic transform" allows displacement, scaling, skew, and rotation. He cannot be conical or angular distorted. For example:

 

"Transformation matrix" is a 3x3 matrix:

A-X Scale (X axis scaling)

B-Y skew (Y-axis skew)

C-X skew (X axis skew)

D-Y Scale (Y-axis scaling)

TX-X translation (X axis displacement)

Ty-Y translation (Y-axis displacement)

U, V, and W are constants 0, 0, and 1 respectively. The following "transformation matrix" is obtained ":

 

The formula for "transformation matrix" is (U, V, W are not used as attributes in the matrix class ):

X' = x * A + y * C + Tx

Y' = x * B + y * D + ty

X' and y' are the final locations of X and Y.

 

Default matrix:

X' = x * 1 + y * 0 + 0 y' = x * 0 + y * 1 + 0

The result is x' = x y' = y.

 

Application Transformation:

X' = 2 * x + 0 * Y + 0 = 2x

Y' = 0 * x + 1 * Y + 0 = y

----------------------------------------------------------------------------------

X' = 1 * x + 1 * Y + 0 = x + y

Y' = 0 * x + 1 * Y + 0 = y

----------------------------------------------------------------------------------

The rotation is achieved by multiplying the values A, B, C, and D with corresponding trigonometric functions.

The formula is as follows:

X' = cos (angle) * X-sin (angle) * Y + 0

Y' = sin (angle) * x + cos (angle) * Y + 0

P.s.

Angle is the Rotation Angle in radians. It is different from the rotation attribute mentioned above. The rotation attribute is the rotation angle in degrees.

Radian = arc length/radius.

The circumference of a circle is 2 π * radius, so the circumference angle (360 degrees) is 2 π radians.

An angle (180 degrees) is 2 π/(360/180) = π radian.

A right angle (90 degrees) is 2 π/(360/90) = π/2 radian.

 

Create a matrix object:

Import flash. Geom. matrix;

VaR my_matrix: matrix = new matrix ();

VaR my_matrix_d: matrix = new matrix (,); // create the default Matrix

 

Common Methods of matrix classes:

Translate (TX: Number, Ty: Number): void // displacement settings

Scale (SX: Number, Sy: Number): void // scaling settings

Rotate (angle: Number): void // rotation settings

P.s.

Angle is the Rotation Angle in radians. It is different from the rotation attribute mentioned above. The rotation attribute is the rotation angle in degrees.

Identity (): void // Reset

As skew is not a typical conversion, there is no way to provide a method. It can be done by manually adjusting the B and C attributes of the object.

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.