# Matrix4x4 矩阵

Struct

A standard 4x4 transformation matrix.

A transformation matrix can perform arbitrary linear 3D transformations (i.e. translation, rotation, scale, shear etc.) and perspective transformations using homogenous coordinates. You rarely use matrices in scripts; most often using Vector3s, Quaternions and functionality of Transform class is more straightforward. Plain matrices are used in special cases like setting up nonstandard camera projection.

Consult any graphics textbook for in depth explanation of transformation matrices.

In Unity, Matrix4x4 is used by several Transform, Camera, Material and GL functions.

### Variables变量

• Access element at [row, column].
访问在[row, column]处的元素。
• Access element at sequential index (0..15 inclusive).
按顺序索引访问元素（包含0..15）。
• The inverse of this matrix (Read Only).
矩阵的反向（只读）。
• Returns the transpose of this matrix (Read Only).
返回这个矩阵的转置（只读）。
• Is this the identity matrix?
这是单位矩阵么？

### Functions函数

• Get a column of the matrix.
获取矩阵的一列。
• Returns a row of the matrix.
返回矩阵的一行。
• Sets a column of the matrix.
设置矩阵的一列。
• Sets a row of the matrix.
设置矩阵的一行。
• Transforms a position by this matrix (generic).
通过这个矩阵变换位置。
• Transforms a position by this matrix (fast).
通过这个矩阵变换位置（快）。
• Transforms a direction by this matrix.
通过这个矩阵变换方向。
• Sets this matrix to a translation, rotation and scaling matrix.
设置这个矩阵为一个平移、旋转和缩放矩阵。
• Returns a nicely formatted string for this matrix.
返回这个矩阵格式化好的字符串。

### Class Variables类变量

• Returns a matrix with all elements set to zero (Read Only).
返回所有元素都设置为0的一个矩阵（只读）。
• Returns the identity matrix (Read Only).
返回单位矩阵（只读）。

### Class Functions类函数

• Multiplies two matrices.
两个矩阵相乘。
• Creates a scaling matrix.
创建一个缩放矩阵。
• Creates a translation, rotation and scaling matrix.
创建一个平移、旋转和缩放矩阵。
• Creates an orthogonal projection matrix.
创建一个正交投影矩阵。
• Creates a perspective projection matrix.
创建一个透视投影矩阵。
Page last updated: 2011-2-26