Matrix4x4矩阵 api
2021-05-04 00:28
A standard 4×4 transformation matrix.
一个标准的4×4变换矩阵。
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.
一个变换矩阵可以表达任意的线性3D变换(例如平移,旋转,缩放,切变等)并且使用齐次坐标系进行投影变换。我们基本上不会在脚本中使用矩阵;通常都直接使用三维向量、四元数以及Transform对象的函数。在特殊的场合例如设置一个非标准化的摄像机投影时才使用纯粹的矩阵。
Consult any graphics textbook for in depth explanation of transformation matrices.
参考任意一本图形学对于变换矩阵的深入解释。
In Unity, Matrix4x4 is used by several Transform, Camera, Material and GL functions.
在Unity中,Matrix4x4对象被很多Transform,Camera,Matierial和Gl中的函数使用。
Matrices in unity are column major. Data is accessed as: row + (column*4). Matrices can be indexed like 2D arrays but in an expression like mat[a, b], a refers to the row index, while b refers to the column index (note that this is the opposite way round to Cartesian coordinates).
Unity中的矩阵使用的是列优先。数据通过行+(列*4)的方式获取。矩阵可以被索引为类似二维数组的形式,但是要以mat[a,b]这样的表达式。其中a代表行号,b代表列号(注意这正好与笛卡尔坐标系相反)。