问题
I tried to understand the mathematics behind the projection matrix and I found this page. The matrix from this page:
I found this matrix is similar to the matrix of Xna.
I understood how they got to m33 and m44 columns of the matrix, but how they got to m11 and m22? And I didn't understand why I have to give the aspect ratio if I already give the field of view angle.
The last thing I want to know is: what is the equation for transfaring from ndc space to window space and how they get to this equation?
回答1:
The FOV would be enough if screens were round... but they are rectangular so just the FOV isn't enough. The FOV is set for screen hieght and the other is the FOV times the ratio of screen width to height.
m11 can be though of as a way to scale the FOV in the width direction. m22 can be thought od as a way to scale the FOV in the height direction.
回答2:
You can change the field of view by just scaling the resulting x and y coordinates: you scale them up, you'll get smaller field of view (zoom in), you scale them down you'll get bigger field of view (zoom out). Perspective projection used in 3D software is rectilinear, so if your field of view is large enough the distortion at the edges will be severe, and you cannot have more than 180° field of view.
You need the aspect ratio, because the clip coordinates in OpenGL and Direct3D run from -1 to 1. In horizontal direction -1 is the left, 1 is the right. On vertical direction -1 is the bottom, 1 is the top. So if you want your squares really appear as a square, you'll need to scale down the X coordinate with the aspect ratio.
来源:https://stackoverflow.com/questions/9646359/projection-matrix