To get from getting started to mastering a language, the best learning documents are official documents, such as OpenCV's learning, the most authoritative learning materials or their official learning documents, the best learning Primer for C # and. NET, or MSDN. But many people do not really use it at first, so they ignore the precious material and learn some other messy material or books.
I've just learned a little bit about MSDN: If you're looking for a class usage or some class usage, just look at the namespace of the class in MSDN, and it will tell you a lot about it. Let's start with the Matrix class under the System.Drawing.Drawing2D namespace.
Overview:
This class encapsulates a 3x3 affine matrix that represents a geometric transformation. This class cannot be inherited.
Namespaces: System.Drawing.Drawing2D
Assembly: System.Drawing (in System.Drawing.dll)
Usage:
In GDI +, you can store affine transformations in a matrix object. Because the third column of the matrix that represents the affine transformation is always (0,0,1), when you construct a matrix object, you only need to specify 6 numbers for the first two columns. Statement:
New
Constructs the matrix shown in the following graphic.
Composite transformations
A composite transformation is a sequence of transformations, one after the other, to see the matrices and transformations in the following list (the essence of the matrix is a transition (transformation) of the space in which it resides):
Matrix A |
Rotate 90 degrees |
Matrix B |
Scale twice times in the x direction |
Matrix C |
Pan 3 units in the Y direction |
In affine spaces, if you start with a point (2,1) represented by a matrix [2 1 1], multiplying by a, B, and C successively, the points (2,1) undergo three transformations in the order listed.
[2 1 1] ABC = [-2 5 1]
Instead of storing the three parts of a composite transformation in three separate matrices, you can multiply A, B, and C together to get a single 3x3 matrix that stores the entire composite transformation. Assuming abc=d, the result of multiplying a point by D is the same as a point successively multiplied by a, B, and C.
[2 1 1] D = [-2 5 1]
Shows matrices A, B, C, and D
The matrix of a composite transformation can be obtained by multiplying several individual transformation matrices, which means that any sequence of affine transformations can be stored in a single Matrix object.
Note: The order of the composite transforms is very important. In general, it's different to rotate, zoom in, then pan, and then zoom, rotate, and pan. Similarly, the order in which matrices are multiplied is also important. This corresponds to the matrix ABC is generally different from the BAC.
The Matrix class provides several processes for building composite transformations: Multiply, Rotateat, Rotate, scale, shear, and translate. The following example creates a composite transformation (select 30 degrees, then scale twice times in the Y direction, and then pan 5 units in the X direction).
New Matix (); //Initializes a new instance of the Matrix class to the unit matrix
Mymatrix.rotate (30);
Mymatix.scale (1, 2, matrixorder.append);
Mymatix.translate (5, 0, matrixorder.append);
Where MatrixOrder's two properties do not know how to play? discussed later.
Link address: Https://msdn.microsoft.com/zh-cn/library/system.drawing.drawing2d.matrix (v=vs.110). aspx
Https://msdn.microsoft.com/zh-cn/library/system.drawing.drawing2d.matrixorder (v=vs.110). aspx
[C # Reference] Matrix class