[Excerpt] matrix learning-Basic Knowledge

Source: Internet
Author: User

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

Previously, I learned about matrices in linear algebra and had some knowledge about the basic operations of matrices. I learned how to use matrices to change images when I used GDI + some time ago, after reading this article, I will summarize it here.

First, let's take a look at the 3x3 matrix, which is divided into four parts. The reason for splitting the data into four parts is described in detail later.

First, we will give you a simple example: after we have set the point P0 (x0, y0) for translation, we will move it to p (x, y), where the translation in the X direction is △x, if the translation in the Y direction is △y, then the coordinates of P (x, y) are:

X = x0 + △x
Y = y0 + △y

The matrix expression is as follows:

The above is similar to the image translation. Through the above matrix, we find that you only need to modify the two elements in the upper right corner of the matrix.

Let's look back at the division of the above matrix:

In order to verify the functional division above, we will give a specific example: now we have set the point P0 (x0, y0) to pan and move it to p (x, y), where X is multiplied by, Y to B,

The matrix is: Verify according to the method similar to the previous "Translation.

The image rotation is slightly complicated: the number of pairs after the θ angle is rotated by P0 (x0, y0) is p (x, y ). By using vectors, we can get the following:

X0 = r cos α
Y0 = r sin α

X = r cos (α-θ) = x0 cos θ + y0 sin θ
Y = r SIA (α-θ) =-x0 sin θ + y0 cos θ

So we get the matrix:

What if the image rotates around a certain point (a, B? First, you need to translate the coordinates to the point, then rotate, and then translate the rotated image back to the original coordinate origin. We will introduce it in detail in the subsequent sections.

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.