Matrices
#1 Members  Reputation: 122
Posted 08 December 2001  10:58 AM
#2 Members  Reputation: 122
Posted 09 December 2001  03:39 PM
[4][5]
[3][4]
It''s not really all that complicated. It just says that if you call block[0][0] it would return a ''4''. block[0][1] would return a ''3'', just so long as your matrix is defined as block[x][y]. Matrices are mainly used for more complex math dealing with vectors, camera transformations, and other junk; however, they can all be used to store 2d tile maps which is a plus. Check out the Articles section here at GameDev, go over to Math, then Matrices. I believe there is an article about matrix math. It explains the concept of various matrix operations, with code in C++, which you probably won''t want. Hope this helps,
Good luck,
Jesse
#3 Members  Reputation: 2076
Posted 09 December 2001  05:14 PM
quote:
Original post by Bravolino
...what is a matrix?
That''s a fairly existential (but simple to answer) question! A matrix is a rectangular array of numbers or functions. The next question is where the "sheezy" hits the "feezy":
quote:
...what does it mean?
This is related to your "what is it good for" question, and is unbelievably hard to answer (because there is no definite answer). A matrix''s meaning is dependent on the field and circumstance under consideration; it can represent pretty much any kind of linear relationship or transformation from one system to another. In condensed form.
[ GDNet Start Here  GDNet FAQ  MS RTFM  STL  Google ]
Thanks to Kylotan for the idea!
#4 Members  Reputation: 113
Posted 09 December 2001  05:40 PM
Rx Ry Rz 0
Ux Uy Uz 0
Dx Dy Dz 0
Px Py Pz 1
R = right vector
U = up vector
D = direction vector
P = position vector
the R, U, and D vectors have to be "orthogonal", which means they have to be at right angles to each other, just like the xyz axis. they also have to be "unit vectors", meaning their length has to be 1.
if the vectors aren''t orthogonal, then you will sheer or streach the object, and if they''re not unit vectors, you will scale the object along the particular nonunit vector. so if the up vector''s lenth was 2, the object would be twice as tall.
there are two types of matrix operations, one is vector/matrix multiplication and the other is matrix/matrix multiplication. since a 3d model is defined with vectors, to "transform" the model from it''s local coordinate system to world coordinates, you''d multiply each vertex in the model by its orientation matrix. you can also multiply two orientation matricies to compose a "compound orientation". this is used in cases where you have an object with some subobjects, such as a human body and arms/legs, or a tank with a rotating gun.. the tank has it''s orientation, and the gun has it''s orientation, but the gun''s orientation is relative to the tank''s orientation, so if the tank turns it affects the gun as well, even though the gun might be sitting still.
so to transform the tank model, you''d just have to multiply it by the tank orientation, but to transform the gun model, you''d have to multiply it first by the tank orientation and then by the gun orientation, or multiply the tank orientation by the gun orientation and then transform the gun model by the compound matrix.
#5 Anonymous Poster_Anonymous Poster_* Guests  Reputation:
Posted 10 December 2001  11:37 AM
Here''s a partial explanation: Points have a set of values for a given coordinate system, generally x,y,z. So do vectors, so we can look at points as if they were vectors. A vector always has a coordinate system that it is relative to. Unless otherwise noted people assume that you are using the normal coordinate system. Coordinate systems themselves are defined using a set of vectors, called a "basis". The basis used to define our normal x,y coordinate system has two vectors, 1,0 and 0,1, but written vertically. When we write it as a matrix it looks like this:
1 0
0 1
the left side is the vector for the x dimension and the right side is for the y. Now let''s do a little matrix multiplication, since this is matrix multiplication you generally put what you are multiplying by on the left (AB is not the same as BA!). I''m going to use . to format. Let''s multiply 2,3 by the basis of normal 2d space
......2
......3
1 0 = 2
0 1 = 3
we get the same vector back. What if we use a different coordinate system?
......2
......3
2 0 = 4
0 2 = 6
now the vector is bigger, why? Well the original vector was in a coordinate system twice as big as the normal one. To bring the vector into our normal system we multiply by the basis of the space we are leaving. You see 2,0 and 0,2 were the vectors that the axis of the bigger space were relative to. It is hard to explain. Now thing about this, what if instead of 0''s we had different numbers? If you do things right you can use a matrix to rotate a vector. Remember a vector is just a point. What if you want to rotate all the points on your 3d model? Just use a matrix. This stuff is hard to teach online so I suggest you take a linear algebra course at a college. It is considered to be respectable math (math majors take it, english majors don''t) but the only real prereq is basic algebra. So take a class if you can.
#6 Members  Reputation: 122
Posted 10 December 2001  02:03 PM
Mike
#7 Anonymous Poster_Anonymous Poster_* Guests  Reputation:
Posted 10 December 2001  03:06 PM
#8 Members  Reputation: 276
Posted 10 December 2001  05:26 PM
As for storing tile data in arrays, a basic example might go like this:

And then you would use two for statements to (one for each "dimension" of the array) and output what it find there. I'm just a newbie, so maybe this is a bad way to do this, but I find that using a case statement and outputting a tile based on the number in the array is pretty effective. The loop part is similar to the following:

Those of you who know what you're talking about, please correct me if I'm not making any sense
Edited by  Peon on December 10, 2001 12:28:47 AM
#11 Anonymous Poster_Anonymous Poster_* Guests  Reputation:
Posted 11 December 2001  02:30 PM
Cheers
D
#12 Members  Reputation: 122
Posted 13 December 2001  11:53 AM
Dammit, I''m in grade 12 and my damn curriculum doesn''t cover them. So I don''t get to learn squat, instead I get to learn how to calculate how many different was a f*cking ball can fall down ''n'' connected tubes. A bunch of useless crap THAT is.