Derivation of Method Transformation Matrix in 3D Transformation
Pan Li Liang 2003-11-23
XheartBlue@etang.com
In a 3D geometric pipe, the input vertices should pass through a series of transformations, and finally transform to a projection space, after removing the last Z-coordinate is a regular 2D screen coordinate. Transformation is usually divided into two steps, one is the view / model transform (D3D is opened into two transformation world transformations and view transformations), and the other is the projection transform Project.
When we don't want to specify a method for a vertex, a polygonal vertex is automatically calculated by the system, and the calculated method is to make a fork by the two edges of the vertex (when the spending is Pay attention to the direction of the spending), which is usually performed after transitioning to the view space. So usually we don't have to care about how to transform to the view space. (Why is the view space? Instead of projection, projection space after projection? The reason is that the lighting and other calculations are performed in the need for the parameters in the view space. The coordinates in the projection space are just for cropping and z-test).
So when will we need to care about how to transform? No one can say it. But it must be needed. For example, when you write a Vertex Shader, maybe you need to use the normal vector, then you need to transform it to the view space with the correct transformation method ------ Of course you If you want to write a software renderer ....... Below I first use the mathematical formulas to strictly derive the transform formula, and then explain some other misunderstandings.
Suppose: Our Model View transform matrix is
,
Method in the world space,
Two vertices in the world space, the planes of the two vertices and
vertical. Then we have the following relationships soon.
, which is
with
The point is zero. Remind everyone here. It can also be seen as an operation. So we write it
---------(1). (
Here, the matrix is multiplied here.
for
The transposition matrix, the same below).
If we mark
for
Transform points in the view space and the corresponding method, we also have
--------(2)
---------- (3)
Sedi 1,2,3
Here we have obtained the transformation formula of the normal vector
. among them
Transform matrices for Model View. (Note, do not multiply the projection matrix).
When we use the method of use, the biggest misunderstanding is to directly convert the Model View transform matrix.
When the method is used to transform the matrix, and some people have once thought that this is correct, and their reasons are two: First, the normal vector is also a vector. And Vertics is also a vector. Why isn't it the same matrix? Second, when I use the Model View matrix to transform the way, the result is also correct. For the first reason, I can only tell you: the normal vector represents a direction, and the vertex represents a location, which is different. For the second reason, it is mainly how everyone has forgotten the linear algebra. If a transform matrix only contains rotation, it must be a orthogonal matrix, namely:
And, there is still
Relationship. A combination can be seen in a transformation containing only rotation. The transformation matrix of the normal vector is indeed the Model View matrix. However, if the transformation contains non-orthogonal factors, such as translation, error, etc. That case is different. Even if you see the so-called correct result. That is also approximately correct, at least in theory, it is incorrect ^ _ ^.
REFERENCE:
Real-time rendering
Heart blue --- Pan Li Liang: 2003-12-7 Completed
Stanly lee.2003-12-7email: XheartBlue@etang.com
Home: http://gamehunter.3322.net/xpertsoft/
QQ: 81496744 Welcome to exchange