# modelview matrix

In my program, I change the modelview matrix with a matrix Q. Q, of course, is a 4x4 matrix because that’s what the modelview matrix is. However, I want to apply Q to a vector representing a point P(x,y,z) which is 3 dimensions. What does the 4th variable in the modelview matrix represent? How would I rotate P by Q? Should I just multiply P by the upper-left 3x3 matrix in Q?

The forth value is 1 or zero depending on the whether you have a point or vector.

For vector [x y z 0]. Now add two vectors

v1+v2 = [x1 y1 z1 0]+[x2 y2 z2 0] = [x1+x2 y1+y2 z1+z2 0]

so addition of two vectors is a vector. What about a point and vector? We use a 1 to denote a point

v+p = [x y z 0]+[xp yp zp 1] = [x+xp y+yp z+zp 1]

which makes sense, a vector translate a point

What if we subtract two points?

p1-p2 = [x1 y1 z1 1]-[x2 y2 z2 1] = [x1-x2 y1-y2 z1-z2 0]

and we know the difference of two points is a vector.

Here is the interesting part. What if you add two points?

p1+p2 = [x1 y1 z1 1]+[x2 y2 z2 1] = [x1+x2 y1+y2 z1+z2 2],

With regular linear algebra, addition of two points just doesn’t make sense. But how come we can take the average of two points?

midpoint = (p1+p2)/2

which is an addition of points. This is because we are taking a linear combination of the points. As long as the coefficient of the sum

c0p0 + c1p1 + … cnpn

add to 1, we are okay. Going back to the addition of points [x1+x2 y1+y2 z1+z2 2], we need to normalize the weights so the 2 becomes 1
so [(x1+x2)/2 (y1+y2)/2 (z1+z2)/2 1] is the sum of p1+p2.

Note that the transformation matrices will equally work properly. In fact, without a system like this , we would not be able to represent translation with a matrix.

• Points are in a so called linear space
• Vectors are in vector space
but they are disjoint, we join them by adding a coordinate. This is called homogeneous (sp?) space or coordinate.

Note that, we cannot represent projections properly in this space, so there is another, called Gaussian space…

Hope this is helps.

Thank you!