# 转换的矩阵表示形式Matrix Representation of Transformations

M × n 矩阵是一组按 m 行和 n 列排列的数字。An m×n matrix is a set of numbers arranged in m rows and n columns. 下图显示几个矩阵。The following illustration shows several matrices.

M × n 矩阵可以乘以 n × p 矩阵，并且结果为 m × p 矩阵。An m×n matrix can be multiplied by an n×p matrix, and the result is an m×p matrix. 中的第一个矩阵的列数必须与第二个矩阵中的行数相同。The number of columns in the first matrix must be the same as the number of rows in the second matrix. 例如的 4 × 2 矩阵 2 的 × 3 矩阵来生成的 4 × 3 矩阵相乘。For example, a 4×2 matrix can be multiplied by a 2×3 matrix to produce a 4×3 matrix.

(a、 b） • (c，d) = ac + bd(a, b) • (c, d) = ac + bd

(a、 b、 c） • （d、 e、 f） 有 + = ad + cf(a, b, c) • (d, e, f) = ad + be + cf

C （i，j） = （第 i，A 的行） • （列 j 的 B）C(i, j) = (row i of A) • (column j of B)

GDI+GDI+可以存储在仿射转换Matrix对象。In GDI+GDI+ you can store an affine transformation in a Matrix object. 因为表示仿射转换矩阵的第三个列始终为 （0，0，1），你在前两个列中指定六个数字，在构造时Matrix对象。Because the third column of a matrix that represents an affine transformation is always (0, 0, 1), you specify only the six numbers in the first two columns when you construct a Matrix object. 语句`Matrix myMatrix = new Matrix(0, 1, -1, 0, 3, 4)`构造前面的图中所示的矩阵。The statement `Matrix myMatrix = new Matrix(0, 1, -1, 0, 3, 4)` constructs the matrix shown in the preceding figure.

## 复合转换Composite Transformations

[2 1 1]ABC = [-2 5 1][2 1 1]ABC = [-2 5 1]

[2 1 1]D = [-2 5 1][2 1 1]D = [-2 5 1]

Matrix类提供用于构建复合转换的多种方法： MultiplyRotateRotateAtScaleShear，和TranslateThe Matrix class provides several methods for building a composite transformation: Multiply, Rotate, RotateAt, Scale, Shear, and Translate. 下面的示例创建一个复合转换，它首先旋转 30 度，然后按 y 方向的 2 倍缩放并会将 5 个单位在 x 方向的转换的矩阵。The following example creates the matrix of a composite transformation that first rotates 30 degrees, then scales by a factor of 2 in the y direction, and then translates 5 units in the x direction:

``````Matrix myMatrix = new Matrix();
myMatrix.Rotate(30);
myMatrix.Scale(1, 2, MatrixOrder.Append);
myMatrix.Translate(5, 0, MatrixOrder.Append);
``````
``````Dim myMatrix As New Matrix()
myMatrix.Rotate(30)
myMatrix.Scale(1, 2, MatrixOrder.Append)
myMatrix.Translate(5, 0, MatrixOrder.Append)

``````