#### Archived

This topic is now archived and is closed to further replies.

# how does projection matrix work?

This topic is 5531 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I looked for it but I couldn''t find about the mathematics of projection matrix. do someone explain it on web? serdar

##### Share on other sites
http://tc1.chemie.uni-bielefeld.de/doc/OpenGL/hp/Reference/glFrustum.html

##### Share on other sites
The PROJECTION_MATRIX (PM) matrix is used to multiply your MODELVIEW_MATRIX(MM)

point = MM * MP * original_point

After this OpenGL apply z division, clipping,...to project point in the viewport.

You know that you set up PM using directly glFrustum() or gluPerspective()...gluPerspective() fill the PM with this algorithm I found

here is gluPerspective source code (Mesa 3.0):

void APIENTRY gluPerspective( GLdouble fovy, GLdouble aspect,GLdouble zNear, GLdouble zFar ){GLdouble xmin, xmax, ymin, ymax;ymax = zNear * tan( fovy * M_PI / 360.0 );ymin = -ymax;xmin = ymin * aspect;xmax = ymax * aspect;glFrustum( xmin, xmax, ymin, ymax, zNear, zFar );}

To read PM you use glGetFloatv(GL_PROJECTION_MATRIX, float16)

To read info from this matrix I have resolved the (simple) system

   // I've used different notation...sorry!//  // However this is the matrix//  A  0  E  0//  0  B  F  0//  0  0  C  D//  0  0  -1 0// We must transpose// frustumMatrix is the PM as it is from glGet REAL A = frustumMatrix[0];REAL B = frustumMatrix[5];REAL C = frustumMatrix[10];REAL D = frustumMatrix[14];REAL E = frustumMatrix[8];REAL F = frustumMatrix[9];// The paramsREAL n = D/(C-1); REAL f = D/(C+1);REAL l = n * (E - 1) / A;REAL r = n * (E + 1) / A;REAL b = n * (F - 1) / B; REAL t = n * (F + 1) / B;

So you get l,r,b,t,n,f that describe your projection: n and f are znear and zfar; l,r,b,t describe the rectangle on znear that is mapped exactly on the viewport.

[edited by - blizzard999 on October 22, 2003 6:51:54 AM]

[edited by - blizzard999 on October 22, 2003 6:53:15 AM]

##### Share on other sites
To be more precise, the projection matrix us used to transform points from eye cordinates to clip coordinates.

Vertex transformation stages:

From the Red Book, chapter 3

[edited by - benjamin bunny on October 22, 2003 9:05:19 AM]

1. 1
2. 2
3. 3
4. 4
Rutin
13
5. 5

• 26
• 11
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633701
• Total Posts
3013435
×