Something seems funny about the way that Android's frustumM works. If I check the OpenGL red book, the matrix generated looks like this:
![](https://i.stack.imgur.com/AJvpX.gif)
(source: glprogramming.com http://www.glprogramming.com/red/images/Image23.gif)
Songho.ca seems to agree with this:
![](https://i.stack.imgur.com/WFNOi.png)
(source: songho.ca http://www.songho.ca/opengl/files/gl_projectionmatrix_eq16.png)
However, one component is multiplied by 2 with Android's frustumM, and not in the other example matrices. Here's what it seems to be doing:
![](https://i.stack.imgur.com/6aL18.png)
一切似乎在功能上都匹配,except第一行,第三列。为什么要乘以二?以下是 android.opengl.Matrix 的 frustumM 方法中的代码行,用于生成第三列的前三个元素:
final float A = 2.0f * ((right + left) * r_width);
final float B = (top + bottom) * r_height;
final float C = (far + near) * r_depth;
将 r_width、r_height、r_depth 定义为:
final float r_width = 1.0f / (right - left);
final float r_height = 1.0f / (top - bottom);
final float r_depth = 1.0f / (near - far);
以“final float A”开头的行似乎错误地乘以 2。
这是 Android 代码中的错误,还是我只是遗漏了一些东西?我知道如果平截头体是对称的,则该术语会抵消。当使用不对称平截头体运行代码时,生成的矩阵实际上是不同的,并且当相同的向量与这些不同的矩阵相乘时得到的向量也是不同的。