收藏 分销(赏)

矩阵转换表示(翻译).docx

上传人:pc****0 文档编号:6380279 上传时间:2024-12-07 格式:DOCX 页数:5 大小:45KB 下载积分:10 金币
下载 相关 举报
矩阵转换表示(翻译).docx_第1页
第1页 / 共5页
矩阵转换表示(翻译).docx_第2页
第2页 / 共5页


点击查看更多>>
资源描述
This article copy form MSDN 2001. mk:@MSITStore:C:\Program%20Files\Microsoft%20Visual%20Studio\MSDN\2001OCT\1033\gdicpp.chm::/hh/gdicpp/cpp_aboutgdip05_00c4.htm Platform SDK: GDI+ Translate By guozhengkun 转换矩阵表示 一个 m×n matrix is a set of numbers arranged in m rows and n columns. The following illustration shows several matrices. 一个m×n 矩阵是m行n列的一组数字集合。下图列出了几种矩阵。 You can add two matrices of the same size by adding individual elements. The following illustration shows two examples of matrix addition. 你可以通过矩阵每个元素相加实现两个大小相同的矩阵的加法运算 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. For example, a 4×2 matrix can be multiplied by a 2×3 matrix to produce a 4×3 matrix. 一个 m×n 矩阵乘以 n×p 矩阵, 结果是m×p 矩阵. 第一个矩阵的列数必须和第二个矩阵的行数相同才能相乘。举例,一个 4×2 矩阵可以通过一个 4×3 矩阵乘以 2×3 矩阵得到。 Points in the plane and rows and columns of a matrix can be thought of as vectors. For example, (2, 5) is a vector with two components, and (3, 7, 1) is a vector with three components. The dot product of two vectors is defined as follows: 平面上的点集和矩阵的行列可以看作向量的集合。例如,(2, 5) 是一个包含两个分量的向量,and (3, 7, 1) 是一个包含三个分量的向量。两个向量的点积定义如下: (a, b) • (c, d) = ac + bd (a, b, c) • (d, e, f) = ad + be + cf For example, the dot product of (2, 3) and (5, 4) is (2)(5) + (3)(4) = 22. The dot product of (2, 5, 1) and (4, 3, 1) is (2)(4) + (5)(3) + (1)(1) = 24. Note that the dot product of two vectors is a number, not another vector. Also note that you can calculate the dot product only if the two vectors have the same number of components. 例如, (2, 3) 和 (5, 4) 的点积等于 (2)*(5) + (3)*(4) = 22。 (2, 5, 1) 和 (4, 3, 1) 等于 (2)(4) + (5)(3) + (1)(1) = 24。注意两个向量的点积是一个数值,不是另一个向量。另外,注意只有分量个数相同的向量才能计算点积。 Let A(i, j) be the entry in matrix A in the ith row and the jth column. For example A(3, 2) is the entry in matrix A in the 3rd row and the 2nd column. Suppose A, B, and C are matrices, and AB = C. The entries of C are calculated as follows: 假定A(i, j) 是矩阵A第i行第j列的项。例如,A(3, 2)是矩阵A的第3行第2列的项。假设A, B 和 C都是矩阵,且AB相乘等于C。C的任一项计算方法如下: C(i, j) = (row i of A) • (column j of B) The following illustration shows several examples of matrix multiplication. 下面插图是了几个矩阵相乘的例子 If you think of a point in the plane as a 1×2 matrix, you can transform that point by multiplying it by a 2×2 matrix. The following illustration shows several transformations applied to the point (2, 1). 如果把平面上一点看作是1行2列的矩阵,你可以通过给该矩阵乘以2行2列矩阵对该点进行坐标变换。下面是点(2, 1)的几个转换应用。 All the transformations shown in the previous figure are linear transformations. Certain other transformations, such as translation, are not linear, and cannot be expressed as multiplication by a 2×2 matrix. Suppose you want to start with the point (2, 1), rotate it 90 degrees, translate it 3 units in the x direction, and translate it 4 units in the y direction. You can accomplish this by performing a matrix multiplication followed by a matrix addition. 上面图形显示的所有变换都是线性变换。另外一些变换,比如平移,就不是线性的,且不能通过乘以2行2列的矩阵来表示。假设你想先把点(2, 1)旋转90度,然后在X方向平移3个单位,Y方向平移4个单位。你可以通过一个矩阵乘法在跟上一个矩阵加法实现。 A linear transformation (multiplication by a 2×2 matrix) followed by a translation (addition of a 1×2 matrix) is called an affine transformation. An alternative to storing an affine transformation in a pair of matrices (one for the linear part and one for the translation) is to store the entire transformation in a 3×3 matrix. To make this work, a point in the plane must be stored in a 1×3 matrix with a dummy 3rd coordinate. The usual technique is to make all 3rd coordinates equal to 1. For example, the point (2, 1) is represented by the matrix [2 1 1]. The following illustration shows an affine transformation (rotate 90 degrees; translate 3 units in the x direction, 4 units in the y direction) expressed as multiplication by a single 3×3 matrix. 一个线性变换(乘以2行2列矩阵)跟一个平移变换(加1行2列矩阵)称为一个仿射变换。可选的,用一对矩阵(一个线性变换和一个平移变换)存储仿射变换是把完整的变换存储在一个3行3列的矩阵中。为了完成这个工作,平面上一点必须存储为带一个第3维虚拟坐标的1行3列矩阵。通用的做法是使第3维坐标等于1。例如,点(2, 1) 被表示为矩阵 [2 1 1]。下图是把一个仿射变换 (旋转90度; X方向平移3个单位, Y方向平移4个单位) 表示为乘以单个的3行3列矩阵。 In the previous example, the point (2, 1) is mapped to the point (2, 6). Note that the third column of the 3×3 matrix contains the numbers 0, 0, 1. This will always be the case for the 3×3 matrix of an affine transformation. The important numbers are the six numbers in columns 1 and 2. The upper-left 2×2 portion of the matrix represents the linear part of the transformation, and the first two entries in the 3rd row represent the translation. 在上面的例子中,点(2, 1) 被映射为点 (2, 6)。注意3行3列矩阵的第三列包含数字0, 0, 1,对于一个3行3列仿射变换矩阵总是这样的。重要的数字是第一列和第二列的6个数字。矩阵左上2×2部分代表线性变换,然后第三行的两项表示平移变换。 In GDI+ you can store an affine transformation in a Matrix object. 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. The statement Matrix myMatrix(0.0f, 1.0f, -1.0f, 0.0f, 3.0f, 4.0f); constructs the matrix shown in the previous figure. 在GDI+中,你可以使用矩阵对象存储仿射变换。因为表示仿射变换的矩阵第三列总是(0, 0, 1),你只需要指定第一列和第二列的6个数字来构造矩阵对象。语句Matrix myMatrix(0.0f, 1.0f, -1.0f, 0.0f, 3.0f, 4.0f); 构造的矩阵显示在上图中。 Composite Transformations 复合变换 A composite transformation is a sequence of transformations, one followed by the other. Consider the matrices and transformations in the following list: 一个复合变换是一组变换,一个接一个。考虑下面列出的矩阵和变换: Matrix A    Rotate 90 degrees Matrix B    Scale by a factor of 2 in the x direction Matrix C    Translate 3 units in the y direction If we start with the point (2, 1) — represented by the matrix [2 1 1] — and multiply by A, then B, then C, the point (2,1) will undergo the three transformations in the order listed. 如果我们把一个点(2, 1) — 表示成矩阵 [2 1 1] - 然后乘A,再乘B,在乘C,那么点 (2, 1) 经历命令表包含的三次变换。 [2 1 1]ABC = [–2 5 1] Rather than store the three parts of the composite transformation in three separate matrices, you can multiply A, B, and C together to get a single 3×3 matrix that stores the entire composite transformation. Suppose ABC = D. Then a point multiplied by D gives the same result as a point multiplied by A, then B, then C. 与其把复合变换的三部分存储在三个独立的矩阵中,不如用A乘B再乘C得到单个的3行3列矩阵存储复合变换。假设ABC = D. 那么点乘以D 得到与点乘A乘B再乘C相同的结果。 [2 1 1]D = [–2 5 1] The following illustration shows the matrices A, B, C, and D. The fact that the matrix of a composite transformation can be formed by multiplying the individual transformation matrices means that any sequence of affine transformations can be stored in a single Matrix object. 事实上,复合变换的矩阵可以表示成若干个单独变换矩阵相乘,就是说一个仿射变换序列可以存储在一个矩阵对象中。 Caution  The order of a composite transformation is important. In general, rotate, then scale, then translate is not the same as scale, then rotate, then translate. Similarly, the order of matrix multiplication is important. In general, ABC is not the same as BAC. 警告 复合变换的顺序是非常重要的。一般而言,先旋转,后缩放,再平移与先缩放,后旋转,再平移是不同的。同样,矩阵相乘的顺序也是重要的。一般而言,ABC不等于BAC。 The Matrix class provides several methods for building a composite transformation: Multiply, Rotate, RotateAt, Scale, Shear, and Translate. 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. 矩阵类提供了构建复合变换的几个方法:Multiply, Rotate, RotateAt, Scale, Shear, and Translate。下面的例子创建了一个复合变换矩阵,先旋转30度,然后在Y方向放大2倍,然后x方向平移5个单位。 Matrix myMatrix; myMatrix.Rotate(30.0f); myMatrix.Scale(1.0f, 2.0f, MatrixOrderAppend); myMatrix.Translate(5.0f, 0.0f, MatrixOrderAppend); The following illustration shows the matrix.
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传

当前位置:首页 > 包罗万象 > 大杂烩

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服