PDA

View Full Version : found one error on the opengl tutorial



wangdingqiao
03-19-2014, 08:15 PM
the calculation process in this link Vertex Transformation (https://www.opengl.org/wiki/Vertex_Transformation),have some error.
the perspective projection matrix should be :
glFrustum[left,right,bottom,top,near,far]

matrix = [(2*near)/(right - left),0,(right+left)/(right - left),0;
0,(2*near)/(top-bottom),(top+bottom)/(top-bottom),0;
0,0,(far+near)/(near - far),(2*far*near)/(near - far);0,0,-1,0];

so here we should get:
[10.0000 0.0000 0.0000 0.0000]
[0.0000 1.8182 0.8182 0.0000]
[0.0000 0.0000 -1.0020 -2.0020]
[0.0000 0.0000 -1.0000 0.0000]

I write four functions transformation,glTranslatef,glFrustum ,glViewport to get the result with matlab,
whole process show below:

//four arguments
point = [ 1.5000 1.6000 -99.6000 1.0000];
trans = [ 1.0 2.0 3.0];
frustum = [-0.1, 0.1, -0.1, 1.0, 1.0, 1000.0];
viewport= [0, 0, 800, 600];
,
>> transformation
input point(x,y,z,w): point
input glTranslatef(x,y,z): trans
translate matrix :
[1.0000 0.0000 0.0000 1.0000]
[0.0000 1.0000 0.0000 2.0000]
[0.0000 0.0000 1.0000 3.0000]
[0.0000 0.0000 0.0000 1.0000]
input glFrustum(left,right,bottom,top,near,far): frustum
projection matrix:
[10.0000 0.0000 0.0000 0.0000]
[0.0000 1.8182 0.8182 0.0000]
[0.0000 0.0000 -1.0020 -2.0020]
[0.0000 0.0000 -1.0000 0.0000]
input glViewport(x,y,width,height): viewport
viewport matrix :
[400.0000 0.0000 0.0000 400.0000]
[0.0000 300.0000 0.0000 300.0000]
[0.0000 0.0000 0.5000 0.5000]
[0.0000 0.0000 0.0000 1.0000]
pt in eye coordinates:[2.5000 3.6000 -96.6000 1.0000]
pt in clip coordinates: [25.0000 -72.4909 94.7914 96.6000]
pt in NDC coordinates: [0.2588 -0.7504 0.9813 1.0000]
pt in screen coordinates: [503.5197 74.8730 0.9906 1.0000]

Agent D
03-20-2014, 12:52 AM
If you found an error on a Wiki Page, you might consider using the discussion page on the wiki or directly editing the wiki page.