Projection Matrix

Started by
-1 comments, last by brekehan 15 years ago
I am trying to extract the values used to create a projection matrix. I found the following MSDN page and derived my math from there. Everything comes out correctly, except the far plane. The far plane is very close, but has an error of around .07 . I assume that is due to floating point error? although only one calculation has been done on the matrix. Is there a more accurate way to get that value? I also, don't understand how to get the Fov from the matrix.

   // Disassemble the projection matrix
   float q         = origProjection._33;
   float nearPlane = origProjection._43 / -q;
   float farPlane  = -q * nearPlane / (1.0f - q);
   float width     = 2.0f * nearPlane / origProjection._11;
   float height    = 2.0f * nearPlane / origProjection._22;
   float ratio     = width / height;



Original values near 0.1 far 1000 ratio 1.25 Obtained values near 0.1 far 999.93408 ratio 1.25

This topic is closed to new replies.

Advertisement