There are a lot of introductions to Baidu's search for ".
This is an example in vs2008:
Void example_transpoints (HDC) <br/>{< br/> graphics (HDC); <br/> Pen (color (255, 0, 0,255 )); </P> <p> point points [5] = {<br/> point (50,100), <br/> point (100, 50 ), <br/> point (150,125), <br/> point (200,100), <br/> point (250,150) };</P> <p> matrix (1.0f, 0.0f, 0.0f, 2.0f, 0.0f, 0.0f); </P> <p> graphics. drawcurve (& pen, points, 5); <br/> matrix. transformpoints (points, 5); <br/> graphics. drawcurve (& pen, points, 5); <br/>}< br/>
CodeIn, transformpoints changes the value of points, which is actually an affine transformation. (Here is the transformation in the plane)
Write down the running result and change points:
50,200
100,100
150,250
200,200
250,300
We can see that the result is doubled in the Y axis.
For matrix, it is actually a 3*3 matrix:
|1.0f0.0f0.0f| |0.0f2.0f0.0f| |0.0f0.0f1.0f|
The first and second parameters of matrix are the first element of the first line of matrix and the second element of the first line;
The third and fourth parameters are the first element of the second row of the matrix and the second element of the second row;
The fifth and sixth parameters are the first element of the third row of the matrix and the second element of the third row;
The matrix constructor is described in msdn.
The third column of the Matrix is always [0 0 1] T, so it is omitted.
Why is the third column omitted? Please refer to Baidu entry
Http://baike.baidu.com/view/954621.htm
Take the Translation Transform as an example (Note: You need to transpose ):
|100| |010| |TXTy1|
The third column of several basic operations of the affinator transformation is [0 0 1] T, so it is omitted.
The general form of affine transformation (but it seems that this formula only includes: Translation transformation, Rotation Transformation and scaling transformation, excluding shear transformation ):
| (λ x) COS θ (λ x) sin θ 0 | | X1 Y1 1 | = | x Y 1 | * |-(λ y) sin θ (λ y) COS θ 0 | | X0 y0 1 |
The transformed coordinates are:
X1 = (λ x) x cosine cos θ-(λ y) x cosine sin θ + x0 Y1 = (λ x) x cosine sin θ + (λ y) y cosine cos θ + y0
Where:
(X0, y0) is the original coordinate origin;
θ is the coordinate rotation angle;
λ x and λ y indicate the shrinkage rate of the Original Coordinate System on the X and Y axes. (Note that λ x is a whole, not λ multiplied by X; λ y is the same)