Hi,

Just a quick question. Why does the modelview matrix have a 4th column for transformations. It was my understanding that you can define transformations of point in 3d space by using a 3x3 matrix.

Also what is the 4th row for?

Thanks For Clearing this up. If possible could someone please point me to some detailed clear docs so I can show my maths teacher as he is also interested.

Many Thanks

-Alex

You can only define combinations of scaling and rotation using a 3x3 matrix.

For translations, you have to use something called “homogenous coordinates”, that is, each point in 3d space is represented by a straight line in 4d space by intersecting the line with the w=1 hyperplane (that is, divide each component by w).

All important 3d transformations including translation and projection can be done with a 4d matrix in homogenous coordinates.

Do a google search for “homogenous coordinates”, and you’ll find a lot of detailed papers on this topic.

Well, perhaps it could be explained simplier:

x’ = a*x + b*y + c*z + d*w

This is transformation of x coordinate of vertex defined as (x, y, z, w) by correspnding matrix row (a, b, c, d). I don’t use the a1, a2, a3 notation, because we will focus on just one row of this matrix to transform just x coordinate of vertex.

If you want to scale then you have:

(a, b, c, d) = (scale, 0, 0, 0)

x’ = scale*x + 0*y + 0*z + 0*w

Which gives: x’ = scale * x

If you want to rotate then you have:

(a, b, c, d) = (cos(angle), -sin(angle), 0, 0)

x’ = cos(angle)*x - sin(angle)**y + 0*z + 0w

Which gives: x’ = cos(angle)*x - sin(angle)*y

If you want to translate you have:

(a, b, c, d) = (1, 0, 0, x_translation)

x’ = 1*x + 0*y + 0*z + x_translation*w

Which gives: x’ = x + x_translation*w

Since w coordinate of every vertex is usually set to 1 you get:

x’ = x + x_translation

If you define a vertex with .w=0 then it will be immune to glTranslate, but will react to glRotate/glScale.