[Excerpt] matrix learning-compound changes of images

Source: Internet
Author: User
Matrix learning-in the space of basic knowledge, let's leave a topic: if an image rotates around a certain point P (A, B), first you need to translate the coordinate system to this point and then rotate it, then, the rotated image is moved back to the original coordinate origin.

We need three steps:

    1. Translation-- Shifts the coordinate system to P (A, B );
    2. Rotate-- Rotate the image with the origin as the center;
    3. Translation-- Translate the rotated image back to the original coordinate origin;

Compared with the aforementioned geometric changes of images (Basic geometric changes of images ),Pan -- rotate -- panThis kind of geometric change that requires multiple types of images is calledCompound changes of images.

For a given image, F1, F2, F3 ..... , FN, their change matrices are T1, T2, T3 ..... , TN, image composite change matrix t can be expressed as: t = TnTn-1... T1.

According to the above principle, the change matrix sequence of θ rotating around a certain point (a, B) is:

Based on the above formula, we will give a simple example: rotate around (100,100) 30 degrees (SIN 30 = 0.5, cos 30 = 0.866)
Float F [] = {0.866f,-0.5f, 63.4f, 0.5f, 0.866f,-36.6f, 0.0f, 0.0f, 1.0f };
Matrix =New Matrix();
Matrix.Setvalues(F );
The rotated image is as follows:

Android provides us with a simpler method, as follows:
MatrixMatrix = newMatrix();
Matrix.Setrotate(30,100,100 );
Actual results after matrix operation:

This is exactly the same as the matrix obtained through the formula.

Here we provide another method to achieve the same effect:
FloatA = 100366f, B = 100366f;
Matrix = newMatrix();
Matrix.Settranslate(A, B );
Matrix.Prerotate(30 );
Matrix.Pretranslate(-A,-B );
I will explain it in detail later.

Using a similar method, we can also get:Ratio of relative P (A, B) to [SX, sy] Change Matrix

Http://www.moandroid.com /? P = 1805

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.