View Full Version : How exactly is projection matrix derived?
06-23-2002, 10:19 PM
Whilst there is brief mention of the elements that make up the projection matrix in both the red and blue books, there never was any attempt at explaining *how* these were derived. (it appears to be an amalgamate of shearing, scaling & translation transformations...but this insight by itself isn't particularly helpful)
Can somebody kindly point me to relevant resources, references, websites etc?
A thousand thanks!
06-23-2002, 11:14 PM
inline mat4<T>& mat4<T>::CreateFrustum( T left, T right,
T bottom, T top,
T nearval, T farval)
T x, y, a, b, c, d;
x = (2*nearval) / (right-left);
y = (2*nearval) / (top-bottom);
a = (right+left) / (right-left);
b = (top+bottom) / (top-bottom);
c = -(farval+nearval) / ( farval-nearval);
d = -(2*farval*nearval) / (farval-nearval);
_11 = x; _21 = 0; _31 = a; _41 = 0;
_12 = 0; _22 = y; _32 = b; _42 = 0;
_13 = 0; _23 = 0; _33 = c; _43 = d;
_14 = 0; _24 = 0; _34 = -1; _44 = 0;
inline mat4<T>& mat4<T>::CreatePerspectiveFrustum(T fovy, T aspect, T zNear, T zFar)
T xmin, xmax, ymin, ymax;
ymax = zNear * (T)tan((double)(fovy * M_PI / 360));
ymin = -ymax;
xmin = ymin * aspect;
xmax = ymax * aspect;
return CreateFrustum(xmin, xmax, ymin, ymax, zNear, zFar);
This any help?
06-23-2002, 11:27 PM
Uh, afraid not...I already know from the red and blue books exactly what the elements of the projection matrix are.
What I don't know is *how* they came to be...ie. why are there scaling, shearing, translation transformations incorporated into it? what are the motivations behind these transformation operations? how are they derived? what formulas/principles/concepts used?
06-24-2002, 12:03 AM
I remember in the days before I knew anything about matrices, linear algebra etc., I had to figure out how 3D worked in a kind of common sense way. These 3 lines is what I came up with to project a world transformed vertex to the screen:-
scale = halfscreenheight/vertex_z;
screenx = (vertex_x*scale) + halfscreenwidth;
screeny = (vertex_y*scale) + halfscreenheight;
This any help? http://www.opengl.org/discussion_boards/ubb/smile.gif
06-24-2002, 12:13 AM
Those equations describe basic perspective division using the similar triangles principle. (I'm familiar with that too ;-)
However, it seems the projection matrix that OpenGL implements is a lot more complex. Problem is, I don't know *exactly* what it does. And while I know the "-1" in the 4th row/3rd column is in effect responsible for implementing the perspective transformation, I just don't know what the rest of the elements do...
Isn't there some official documentation on this? SGI's website for instance? (given that they were responsible for OGL's genesis in the early days)
06-24-2002, 12:28 AM
I've just done a quick search on google, and come up with this link - I haven't had time to read it, so it probably doesn't answer your question, but give it a go:-
06-24-2002, 12:32 AM
BTW, here's the google query...have a browse!
06-24-2002, 12:35 AM
Gee, that link you gave answered my question exactly!
(the Google search I tried didn't turn up anything near as useful as this...)
Thanks a lot man!
06-24-2002, 12:39 AM
I tend to put things in quotes when using google, to get the 'exact phrase'.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.