I looked up a wikipedia article on matrices, and I read the whole tiring thing through. I then saw at the end, the computer programmin sections, and it just simple said, to make matrices look 3D, this method uses a four by four matrix, the dimensions are placed on the top row/ left column, and then the rest of the matrix is used to culculate and convert the 2d image to 3D (well, looks like it). So I clicked the link between the mathematical matrix, and the coding matrix. So I saw this
Another type of transformation, of importance in 3D computer graphics, is the perspective projection. Whereas parallel projections are used to project points onto the image plane along parallel lines, the perspective projection projects points onto the image plane along lines that emanate from a single point, called the center of projection. This means that an object has a smaller projection when it is far away from the center of projection and a larger projection when it is closer.
The simplest perspective projection uses the origin as the center of projection, and z = 1 as the image plane. The functional form of this transformation is then x' = x / z; y' = y / z. We can express this in homogeneous coordinates as:
x(c)=1000
y(c)=0100
z(c)=0010
w(c)=0010
(The result of carrying out this multiplication is that (xc,yc,zc,wc) = (x,y,z,z).)
After carrying out the matrix multiplication, the homogeneous component wc will, in general, not be equal to 1. Therefore, to map back into the real plane we must perform the homogeneous divide, i.e. divide each component by wc:
x(I)= x(c)/w(C)
y(I)= y(c)/w(c)
z(I)= z(c)/w(c)
More complicated perspective projections can be composed by combining this one with rotations, scales, translations, and shears to move the image plane and center of projection wherever they are desired.
Last edited by Gigabyte123 (2007-11-10 23:40:34)
Offline
that is what I saw on the wikipedia article, so can someone please tell me what is all this stuff about W? And say the X=2, the Y=5, and the Z=3, how would you use the matrix for this? I know about the mathematical matrix now, but the transformation one is wierd.
Offline
With homogeneous coordinates you carry an extra value in your matrix such that you have [ x y z w ] where w is your extra value. When you're doing normal matrix math w = 1. If you look at a transform matrix that has no perspective transform it might look like this:
t = translation
r = rotation
r r r t
r r r t
r r r t
0 0 0 1
if you apply matrix multiplication to this
r r r t
[x y z 1] * r r r t
r r r t
0 0 0 1
then this allows you to have your translation and rotation factored into the calculation.
x' = x * r + t
y' = y * r + t
z' = z * r + t
w' = 1
In order to get a perspective transformation then the x and y values should get closer to zero for larger values of z. You can do this by calculating your perspective transform in w. If we create the following matrix
1 0 0 0
0 1 0 0
0 0 1 0
0 0 1 0
Then w will be equal to z. You want the resulting w' to be equal to 1, so you have to divide the entire resulting array by w' so that it will still be equal to 1.
x'' = ( x * r + t ) / w'
y'' = ( y * r + t ) / w'
z'' = ( z * r + t ) / w'
w'' = ( z * r + t ) / w'
which basically gives us
x'' = x' / z'
y'' = y' / z'
z'' = 1
w'' = 1
There are a few things you can do to the perspective matrix to get it to fit everything into a particular field of view and to get it so that your final z value actually maps from 0 to 1.
Offline
thanks canthiar. I have to go right now, but I will read your thing later.
Offline
I setup the order of the multiplication wrong. It should be
r r r t x
r r r t * y
r r r t z
0 0 0 1 1
If the vertex is on the left then the transformation matrix will look like this:
r r r 0
[x y z 1] * r r r 0
r r r 0
t t t 1
I also wrote this
x' = x * r + t
y' = y * r + t
z' = z * r + t
w' = 1
as lazy short hand for the full multiplication result.
Offline