Created
May 15, 2013 10:52
-
-
Save anonymous/5583138 to your computer and use it in GitHub Desktop.
Compute OpenGL projection matrix from intrinsic parameters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Matrix4d computeOpenGLProjectionMatrix(const Matrix3d &K, double x0,double y0, double width, double height, double znear, double zfar) | |
{ | |
double depth = zfar - znear; | |
double q = -(zfar + znear) / depth; | |
double qn = -2.0 * (zfar * znear) / depth; | |
Matrix4d OpenGLProjectionMatrix; | |
OpenGLProjectionMatrix << 2*K(0,0)/width, -2*K(0,1)/width, (-2*K(0,2)+width+2*x0)/width, 0 , | |
0, -2*K(1,1)/height,(-2*K(1,2)+height+2*y0)/height, 0, | |
0,0,q,qn, | |
0,0,-1,0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment