View Full Version : What the 3D matrix vectors mean

07-14-2003, 12:18 PM
Hi all! I have a question about the modelview matrix. How are the vectors stored within it, and what do they represent? The OGL Blue and Red books told me a lot about how to transform and multiply the matrices, but I have not found this information.

I know the vectors are composed of x,y,z and w coordinates, so that explains the number of coordinates in the vectors. However, there must be four vectors then, right? So what vectors could they be? Positive x, positive y, positive z and ... what? Also, I saw a reference to a matrix equation for a plane, "Ax + By + Cz + D = 0" in the red book. Does anyone know what D is supposed to represent? The fourth coordinate, w, is also a mystery to me. If anyone would explain that to me, that'd be great!

Finally, when submitting a matrix to openGL in the format m[16] where m is the matrix of GLfloats, m[0] to m[3] is positive x, m[4] to m[7] is positive y, m[8] to m[11] is positive z and m[12] to m[15] is positive w, right? I've done some basic linear algebra, but I don't know how the ARB is representing the 3D positions in the modelview matrix. I'm also aware that this isn't a very advanced question, but I didn't think it was beginner level either, so I posted it here to err on the side of getting an answer. :~)

I'm just trying to climb out of newbie-ism and into the guts of OGL here to do some more powerful stuff. I've been programming in OGL for 2 years and I'm trying to throw together my first real playable-and-enjoyable 3D game. Any help is much appreciated!


07-14-2003, 01:58 PM
You are correct that you can think of the upper left 3x3 sub-matrix in the modelview matrix as a set of basis vectors that define an orientation in space (or a rotation from the default orientation). As far as what the rightmost column represents, it is an offset from the origin....a translation.

When you look at the equation Ax + By + Cz + D = 0, you can think of the A, B, and C as the 3 components of the vector that is normal to the plane. D is the distance of the plane from the origin along that normal vector (so long as it's normalized).

The modelview matrix does not represent just 3d position, rather, it represents a 3d position AND orientation...a coordinate frame.

07-14-2003, 06:25 PM
I believe the last term is actually wD, but w is "almost always" == 1, so that's often a sufficient shortcut.