Java image transformation class-affinetransform

Source: Internet
Author: User
Many people have studied the imation editor of GL, but I don't think everyone can understand the sprite m00 M01 M02 M10 M11 M12 in its XML data file, in fact, they are six parameters of the Java image transformation class affinetransform. Affinetransform is a very important class in j2se for processing 2D image affine transformations, which is often used in game tools. The constructor of this class has six parameters: m00 M10 M01 M11 M02 M12, A matrix [m00 M01 M02] [M10 M11 M12] [0 0 1] is constructed. Pay attention to the order of these six parameters, cocomo used to get the wrong result because of the wrong Parameter order, the most depressing thing is that it was also fooled by Jedi to say that there was a kind of identity matrix that was not stored in [1 0 0 0] [0 1 0] [0 0 1] format, I have not found the problem for half a day. After this matrix is built, then, when the translation is performed, the left side is multiplied by a translation matrix [1 0 TX] [0 1 ty] [0 0 1] When the X is reversed, the left side is multiplied by a scaling matrix [-1 0 0] [0 1 0] [0 0 1] When Y is reversed, the left side is multiplied by a scaling matrix [1 0 0] [0-1 0] [0 0 1] When the rotation is performed, the left side is multiplied by a rotating matrix [cos (theta) -Sin (theta) 0] [sin (theta) Cos (theta) 0] [0 0 1] Then the settransform matrix can be drawn in graphics2d. To get the transformed data, call getmatrix to obtain a double array matrix. Matrix [4] is the X axis offset, and matrix [5] is the Y axis offset. If Matrix [0] <0, x is reversed, and matrix [3] <0, Y is reversed. Double Degree = math. todegrees (math. asin (Matrix [1]); If (degree <0) degree + = 360; then the rotation angle is obtained.

Original: http://j2medev.spaces.live.com/blog/cns! 8d09cff9fe06ed5d! 1065. Entry

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.