Projection matrix question

Started by
3 comments, last by Brother Bob 12 years, 4 months ago
Hello,

I am using OpenSceneGraph, which internally uses OpenGL. I transform a vector from view space to projection space with this code:

Vec4 vecVS(0, 0, -10, 1);
Vec4 vecProj = vecVS * projMat;

The view space vector has coordinates of (0, 0, -10, 1), so I expected the point to have x,y coordinates of 0,0, since the point is exactly in the middle
of the near plane. But when I print vecProj, I surprisingly get these values:

(0.000, -4.512, 8.018, 10.000)
[/quote]
x seems to be correct, but how can y be -4.512? Shouldn't y be 0 too? Has anyone an idea what could be wrong?
Advertisement
How did you make your projection matrix? And what is its value?
The matrix is automatically computed by OpenSceneGraph and looks like this:

(1.732, 0.000, 0.000 0.000)
(0.000, 3.112, 0.000 0.000)
(0.000, 0.451, -1.002 -1.000)
(0.000, 0.000, -2.002 0.000)
What about:
Vec4 vecVS(0, 0, -10, 1);
Vec4 vecProj = projMat * vecVS ; //Or someting like : vecProj = vecVS * transpose(projMat)

?
Given the vector and the projection matrix, the result you get is correct. The question is; why is there a 0.451 in the second element on the third row? That element is what is commonly used as the translation part of the matrix, so it means that you have a non-symmetric projection matrix (it is in the Y-direction, so your projection matrix has, for example, non-symmetric bottom and top values). If that is not what you want, then you have to go back to the source of that matrix and see why it is non-symmetric.

This topic is closed to new replies.

Advertisement