What's a matrix used for?
I''m doing the crossover from 2D to 3D and so far I''ve been able to grasp the basics of 3D, except for matrices. Well to be honest I havn''t -tried- too much yet, but I can''t seem to find any good basic info about them anywhere.
I''m already familiar with vectors, vertices, meshes, etc, including 3D math type stuff but what the heck are matrices? I''m not asking for a whole tutorial just the general idea...
===========================================
As far as the laws of mathematics refer to reality, they are not certain, and as far as they are certain, they do not refer to reality.
-Albert Einstein
You''ll need much more than the general idea to do stuff with matrices. A good algebra books is probably your best start. Matrices are key tools for graphics. They are used to ease vector calculations.
u really should get a tutorial. there''s one right here on gamedev.net.
Matricies are used for most things in 3d. Translation Matrix''s are used to move an object in X,Y, or Z directions. Scaling Matrix''s are used for making Models Larger/Smaller. And rotation matrix''s are used for anything that rotates in 3d. You can also use matrix''s to preform bitmap rotation in 2d.
Joseph FernaldSoftware EngineerRed Storm Entertainment.------------------------The opinions expressed are that of the person postingand not that of Red Storm Entertainment.
The only _real_ reasons to use a matrix are that firstly your screen is a 2d matrix, which makes them handy to use, and that you can stack operations.
For example, using non-matrix means to say, scale up an image by 50% would, providing you knew what you were doing, take about as much time as using a matrix would. There are the same basic number of calculations. However, if you wanted to: scale it up by 50%, translate it 40 units left, warp it, spin it by 50/60/70 degree (x/y/z) and then mirror it in 2D, it becomes an issue.
From basic matrix math, for any NxN transformation matrix, you can then transform a similar matrix (same size; eg. of pixels).
However, 0 * 1 * 2 * 3 * 4 * 5 * 6, with 0 our pixel matrix, and 1-6 the transformations, is EXACTLY THE SAME as:
0 * X, where X = 1 * 2 * 3 * 4 * 5 * 6. Since you can then save X, and keep it around, it mans you can perform many operations on another matrix in one go. Much faster.
There are other reasons too, but basically I think it comes down to that, and its convenient. Its a lot more of a pain to try to figure out non-matrix ways of doing things that matricies make very easy to do.
Since many 3d libs like open gl handle this all on their own, you might never need to know it, but its worth knowing.
Look for a computer graphics book (eg. at library). I disagree on the algebra book idea; its a waste of time. 90% of the book would have nothing to do with what you want. Ideally something like "The math of computer graphics" (I saw that at our library, I dont recall the author unfortunatly). But anything actually on computer graphics would go through it.
For example, using non-matrix means to say, scale up an image by 50% would, providing you knew what you were doing, take about as much time as using a matrix would. There are the same basic number of calculations. However, if you wanted to: scale it up by 50%, translate it 40 units left, warp it, spin it by 50/60/70 degree (x/y/z) and then mirror it in 2D, it becomes an issue.
From basic matrix math, for any NxN transformation matrix, you can then transform a similar matrix (same size; eg. of pixels).
However, 0 * 1 * 2 * 3 * 4 * 5 * 6, with 0 our pixel matrix, and 1-6 the transformations, is EXACTLY THE SAME as:
0 * X, where X = 1 * 2 * 3 * 4 * 5 * 6. Since you can then save X, and keep it around, it mans you can perform many operations on another matrix in one go. Much faster.
There are other reasons too, but basically I think it comes down to that, and its convenient. Its a lot more of a pain to try to figure out non-matrix ways of doing things that matricies make very easy to do.
Since many 3d libs like open gl handle this all on their own, you might never need to know it, but its worth knowing.
Look for a computer graphics book (eg. at library). I disagree on the algebra book idea; its a waste of time. 90% of the book would have nothing to do with what you want. Ideally something like "The math of computer graphics" (I saw that at our library, I dont recall the author unfortunatly). But anything actually on computer graphics would go through it.
actually, what i think gorg meant was LINEAR algebra book. you can''t get any more "matrix" than that. but i would have to agree about the graphics book though. most 3d computer graphics books cover the amount of matrices you need to know. a lin alg book goes way too in depth for game programmer''s purposes. ( i mean modern, commercial games).
what shadow mint is talking about is matrix concatenation, where you can describe all transformations on an object with one "master" matrix, but really, what i think you would encounter as a beginning 3d programmer is matrix manipulations for rotations. there''s lots of material on this site, as everyone says, so read it up, and expand yer mind. oh, and when you run across the word "quaternion," don''t get scared, but see it as an advanced advantage for later on.
a2k
what shadow mint is talking about is matrix concatenation, where you can describe all transformations on an object with one "master" matrix, but really, what i think you would encounter as a beginning 3d programmer is matrix manipulations for rotations. there''s lots of material on this site, as everyone says, so read it up, and expand yer mind. oh, and when you run across the word "quaternion," don''t get scared, but see it as an advanced advantage for later on.
a2k
------------------General Equation, this is Private Function reporting for duty, sir!a2k
In 3d programming 4x4 matrices are often used:
M =
m00 m01 m02 m03
m10 m11 m12 m13
m20 m21 m22 m23
m30 m31 m32 m33
If v is a vector,
M*v = v''
v''.x = m00*v.x + m01*v.y + m02*v.z + m03*v.w
v''.y = m10*v.x + m11*v.y + m12*v.z + m13*v.w
v''.z = m20*v.x + m21*v.y + m22*v.z + m23*v.w
v''.w = m30*v.x + m31*v.y + m32*v.z + m33*v.w
w is a scaling coordinate which is set to 1 in most cases.
If you multiply two matrices A and B, the resulting matrix will contain all transformations of A and B:
M = A*B
mxy = ax0*b0y + ax1*b1y + ax2*b2y + ax3*b3y
GA
M =
m00 m01 m02 m03
m10 m11 m12 m13
m20 m21 m22 m23
m30 m31 m32 m33
If v is a vector,
M*v = v''
v''.x = m00*v.x + m01*v.y + m02*v.z + m03*v.w
v''.y = m10*v.x + m11*v.y + m12*v.z + m13*v.w
v''.z = m20*v.x + m21*v.y + m22*v.z + m23*v.w
v''.w = m30*v.x + m31*v.y + m32*v.z + m33*v.w
w is a scaling coordinate which is set to 1 in most cases.
If you multiply two matrices A and B, the resulting matrix will contain all transformations of A and B:
M = A*B
mxy = ax0*b0y + ax1*b1y + ax2*b2y + ax3*b3y
GA
Visit our homepage: www.rarebyte.de.stGA
Matrices are particularly useful for the world to camera transformation. Because the world to camera transformation is the same for every object in the world, the matrix remains the same, and as it is usually a combination of both translations and rotations it is quicker to work out the world to camera transformation matrix as a combination of the rotations and the translations and then apply that to all the points than to rotate all the points then translate. I learn''t matrices as applied to 3d graphics from the Black Art of 3D Game Programming by André Lamothe. It is quite a good book on software 3d. A linear algebra book would basically be about solving simulataneous equations with more than two unknowns, which is not much use in 3d graphics. Some of the more advanced linear algebra stuff is quite useful for software perspective correct texture mapping.
------------------------------
#pragma twice
------------------------------
#pragma twice
actually, in direct3d and opengl, you have the ability to manipulate a camera viewpoint without dealing with it''s matrix. you''re free to play around with the matrix, but the camera functions are good enough. but, yeah, this is yet another reason why matrices are important to 3d graphics.
a2k
a2k
------------------General Equation, this is Private Function reporting for duty, sir!a2k
Wow, lots of responses... I think I get the idea, it''s basically what I suspected in much more detail
===========================================
As far as the laws of mathematics refer to reality, they are not certain, and as far as they are certain, they do not refer to reality.
-Albert Einstein
===========================================
As far as the laws of mathematics refer to reality, they are not certain, and as far as they are certain, they do not refer to reality.
-Albert Einstein
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement