《Matrices for 3D applications - View transformation》翻译

《Matrices for 3D applications - View transformation》翻译

原文链接:http://knol.google.com/k/matrices-for-3d-applications-view-transformation#Calculation_for_a11
翻译:往昔之剑
时间:2011年5月30日
BLOG:http://jerrycg.com

转载请注明出处!在Google上看到的一篇讲解视图变换的文章,介绍了快速逆矩阵算法,讲的很好,拿来翻译一下。

《Matrices for 3D applications - View transformation》翻译
《矩阵3D应用—视图变换》


Local Coordinate System
局部坐标系统 

This part delves into the local coordinate system transformation. The mathematics of this problem are simple, but elaborate.
这篇文章主要研究局部坐标系统转换。这个问题涉及的数学知识非常简单,但是很复杂。

Contents(正文)
  • Local Coordinate System (局部坐标系统)


    • Calculation for a11(计算a11
    • Calculation for a12(计算a12
    • Inverse matrix(逆矩阵)


      • Adjugated matrix(伴随矩阵)
      • Determinant of A , or |A|(A的行列式,或|A|)
      • Inverse matrix result(求解逆矩阵)


Local Coordinate System
局部坐标系统



Sometimes we need to use a new (local) axis :
  • Camera transform : The camera defines a new local axis, with the location of the camera as a new origin, the view direction of the camera as Z axis (corresponds to the Z-buffer)
  • Normal mapping : Incoming light (a vector) is transformed to the local axis of one triangle of the model. This makes it possible to use the normal map texture for the light calculation.

We want to define a matrix for the following situation :

有时我们需要使用一个新的(局部)坐标:  

  • 摄像机变换:摄像机定义了一个新的局部坐标系,以摄像机的位置作为一个新的原点,摄像机的观察方向为Z轴(相当于深度值)
  • 法线贴图:引入一个灯光(向量)作用到局部坐标系的一个三角形模型上。这将可能使用法线贴图用来计算光照。我们定义一个矩阵用作下面的环境

    
Because we calculate this matrix for a camera transformation, we could also use another notation for the new axises :
我们需要使用另一个新的坐标表示,因此我们来计算这个摄像机变换矩阵:

   

We have a point p1 with coordinates in the world axis [x,y,z]  and we wish to know the coordinates of this point in the new (local) axis [ x', y' , z' ].
在世界坐标 [x,y,z]中,有一个点p1,我们想要知道这个点在新的(局部)坐标系[x’,y’,z’]中的位置


It is important to note that the 3 vector RightUp and Look are vectors expressed in the World Coordinate System. The Eye position is also a coordinate in the World Coordinate System. The new coordinate system is also an orthogonal coordinate system, this means that the Right, Up and Look vectors are orthogonal to one and other. We can write the following :  
注意,RightUpLook这三个向量表示在世界坐标系中。Eye 的位置也在世界坐标系中。这个新的坐标系是一个正交坐标系,这意味着RightUpLook彼此正交。 我们可以得出:  


Right, Up and Look are vector (3 components) so we can write the previous equation as a matrix : 
Right, Up和Look作为上式中矩阵的3个元向量:

   

The following elements are expressed in the original coordinate system ( World Coordinate System) :
下列元素表示在原坐标系中:

 

  • xyz
  • Right
  • Up
  • Look
  • Eye

  The coordinate x' y' z' is the new coordinate , expressed in the Local Coordinate System.
坐标x' y' z'代表新坐标,表示在局部坐标系中。

To calculate x', y' and z' we need to use the properties of inverse matrices :
计算x' y' z',我们需要利用逆矩阵性质。



The calculation of an inverse matrix is a lot of work , but by using the properties of vector cross products we can simplify the calculations.
计算逆矩阵的工作量较大,但是通过逆矩阵的叉积我们可以简化计算。
 

The inverse of a 4x4 matrix A is given by : 
给出一个4x4矩阵的逆矩阵:


或:
A-1 = adj (A) / det (A)  

The calculation for the adjugated matrix is shown for 2 elements (a11 and a12)..
计算伴随矩阵用两个元素表示(a11和a12)  


Calculation for a11 
计算a11

  To calculate a11 we need to calculate the value for a determinant in the original matrix. De determinant is formed by leaving out row 1 and column 1 from the original matrix.
为了计算a11 ,需要算出原始矩阵的行列式。行列式的表示形式,忽略了原矩阵的第一行和第一列。

  
a11 等于:

It is easy to calculate the determinant for a 3x3 matrix :
计算3x3矩阵的行列式很简单:
http://mathworld.wolfram.com/Determinant.html

a11 = Upy * Lookz - Upz * Looky

Calculation for a12

计算a12


a12 is the element in the second row and first column. The determinant is formed by removing the first row and second column from the original matrix :  
a12 是第二行第一列的元素。行列式表示为去除原始矩阵的第一行和第二列:

  
a12 等于:  


Inverse matrix

逆矩阵  

Adjugated matrix

伴随矩阵   Applying the formula to every cell of the adjugated matrix yields :
使用这个公式,每一个伴随矩阵中:
  
或 :
  

This matrix can be simplified by using the properties of orthogonal vectors.
这个矩阵可以利用正交向量简化。

The cross product of 2 of the axises has the third axis as a result. So :
两个坐标叉乘可以得到另一个坐标,因此:

A number of possible simplifications (derived from the cross product)  

Rightx = Upy * Lookz - Upz * Looky Upy = Rightx * Lookz - Rightz * Lookx ...

This simplifies the matrix to :
简化矩阵为:

  

As an example Tx is calculated , Ty and Tz are similar. Again vector cross products are used to simplifiy the equations :
例如,得出TxTy 和 Tz将可以简单求出。再进行一次向量叉乘来简化等式:

得出Ty 和 Tz :  

Determinant of A , or |A|

A的行列式,或|A|

The last step is the calculation of the determinant of A :
最后一步是计算A的行列式:

  

This is a property of orthogonal vectors of length 1.
这是长度为1的正交向量的性质。  


Inverse matrix result

求逆矩阵  

Finally we have a matrix that can transform a vertex from the World Coordinate System to the new Local Coordinate System :
最后我们得到了可以将顶点从世界坐标系转换到局部坐标系的矩阵:  

你可能感兴趣的:(《Matrices for 3D applications - View transformation》翻译)