elo people, i have a question. In fact I still can't get why we use a 4x4 matrix when working with homogeneous coordinates in opengl?? Please help...i've gone into some online tutorials but, still not clear.
elo people, i have a question. In fact I still can't get why we use a 4x4 matrix when working with homogeneous coordinates in opengl?? Please help...i've gone into some online tutorials but, still not clear.
free thinkers are dangerous..
Well, 4x4 matrix is not only specifc to OpenGL. Wehn we recal our graphics fundamental for transformations, 4x4 matrix used to represent the coordinate system on which one of the row & column is dedicated for the x,y,z value.
Originally posted by hanz:
elo people, i have a question. In fact I still can't get why we use a 4x4 matrix when working with homogeneous coordinates in opengl?? Please help...i've gone into some online tutorials but, still not clear.
The matrix is used to transform your current coordinate system into the world coordinate system. The columns of the matrix gives the homogenous coordinates of the local coordinate system relative to the world coordinate system.
To understand why you need 4 components instead of only 3, you have to understand how vectors and points are represented using homogenous coordinates. A coordinate system in 3D space is really composed of 4 components, not 3. They are the 3 axes (x,y,z) and the origin.
Every vector in 3D space is a linear combination of the three axis, so (1,2,1,0) is really the vector 1*x+2*y+1*z+0*w, where x,y,z,w are the columns of the transformation matrix.
Every point in 3D space is given by the origin plus a vector, so (1,2,3,1) is really the point 1*x+2*y*3*z+w, x,y,z,w are again the columns of the matrix.
When you want to transform vertices, you really want to change the local coordinate system. The columns of the transformation matrix are the 4 components (x,y,z and the origin) of the new coordinate system relative to the old one. If you rotate or scale something, you only change the x,y,z components, but if you want to translate something, you need to change the coordinate origin, thus you need the fourth component of the matrix.