View Full Version : viewport matrix and perspective division

fiftycent

08-16-2004, 10:23 AM

I need to know what the exact mathematical matrix representation of the viewport matrix is with respect to glViewport(...) and I need to know the exact matrix representation of the perspective division.

I also need to know how to get the focal length from the projection matrix.

I am trying to find exact pixel locations of the points I am displaying so I can have a ground truth representation for my structure from motion algorithm.

dorbie

08-16-2004, 11:55 AM

Depends how you build your projection matrix, you could do anything in there. OpenGL has the function glFrustum and that clearly documents what goes in the projection matrix, so if you build your projection matrix using that call then you get this:

http://www.esil.univ-mrs.fr/~smavroma/Docs/OpenGL-Man-Pages/glFrustum.html

The transformation to the viewport is also defined as a separate stage but it is pretty intuitive. Basically after homogeneous divide -1 to +1 in x & y map to the viewport edges. i.e. before the homogeneous divide, the raw data out of the matrix gives x=-w, x=+w map to the left and right of the viewport and y=-w, y=+w are the bottom and top of the viewport. If you need information of exact subpixel positioning then see any version of the spec:

http://www.opengl.org/documentation/spec.html

P.S. Actually the transformation is also given clearly in the glViewport man page:

http://www.cs.bham.ac.uk/resources/ums/OpenGL/man/glViewport.html

dorbie

08-16-2004, 12:07 PM

P.P.S. focal length is meaningless in this context. Typically this determines the field of view in photographic systems based on film/sensor size and other configuration parameters. Basically you are asking for the field of view and that can easily be determined from the matrix or the glFrustum parameters.

You need to correlate this with particular focal lengths in your camera system and what field of view they generate on your sensor.

Based on your question and phrasing I think this demo I wrote may interest you:

http://www.sgi.com/software/performer/brew/uav.html

Powered by vBulletin® Version 4.2.3 Copyright © 2018 vBulletin Solutions, Inc. All rights reserved.