Jump to content
  • Advertisement
Sign in to follow this  
fguihen

matrices are a mystery to me. anyone know any good tutorial sites?

This topic is 5409 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi. my question is in the title. i have gone through a few tutorials, but cant seem to grasp matrices, or how im supposed to use them in 3d graphics. can anyone recomment a good tutorial that starts with the basics, and goes as far as rotational matrices, or further, but explains them in relation to 3d graphics. thanks all.

Share this post


Link to post
Share on other sites
Advertisement

Matrix Addition:
(Matrices must have same dimensions)

[ a b c ] + [ h i j ] = [ a+h b+i c+j]
[ e f g ] [ l m n ] [ e+l f+m g+n]


Same applied for subtraction. Most simple, use can use matrices to translate points on the screen. If you want to move a shape, say a triangle where the points are defined as:

x y
-------

[ 0 0 ]
[ 1 1 ]
[ 1 0 ]



Lets say we want to movie it up 5 units, we add 5 to all the values in the right hand colum then graph the result. If we want to move it 5 units up and to the right, we add 5 to all values, then graph that result. From my experience trying out new mathematics for programming projects, it's best to do everything out by hand until you understand it... Don't just start trying to implement it. You might get it to work, but you wont understand anything afterward. Pencil and graph paper are you best friends.

I hope this makes sense... I'd explain it more if I had more time

Share this post


Link to post
Share on other sites
Do you understand direction vectors? Subtract one position from another, and normalize it. The result is a direction vector. A direction vector can point anywhere in 3D space.

This is a really calmed down explaination of matrices pertaining to 3D transformations, and hopefully the math guys won't smack me. I'm not at all a math guy, so feel free to tell me I suck.

A 4x4 matrix has 4 rows and 4 columns. The matrix can be used to rotate and move a position any way you like. Pay most attention to the first top-left 3x3 numbers, and the bottom row's 3 numbers.

The top-left 3x3 is the rotation. Now what is a direction vector? It's like an arrow pointing in one direction. So if you had a direction vector which always pointed north or such, it would be like a compass, right? Well, a real compass would tell you where up is for the planet. A matrix tells you where up is for the rotating transform. That's what the 3x3 numbers are. The first row contains a direction vector which is pointing west. The second has one pointing up, and the third points forward. x, y, z order. Each row points in the positive direction of x, then y, then z. Take a look at the 3x3 area for an identity matrix (which is a matrix with no rotation):
XDirection = 1.0  0.0  0.0 (right)
YDirection = 0.0 1.0 0.0 (up)
ZDirection = 0.0 0.0 1.0 (forward)

Makes sense, right? The topmost 3 numbers are pointing straight right (positive X, because x y z order, first # (x) is 1.0). The second row (up) is saying full Y positive. And the third row is saying 1.0 for Z, which means full positive Z. If you applied a rotation to this matrix, the directions would change. As in if you rotate Y by PI (180 degrees), it would rotate the direction vectors (imagine arrows). YDirection does not change, because the object just turned around; it's up is still the same up. But it's forward and right is now negative.

That is my lame visual respresentation of a 3D transformation matrix. Oh, and the 4th row is just a movement vector. That will detail how much the object is going to move. The movement vector can also change with rotations, if it has a value larger than 0,0,0 when a rotation is applied. But explaining this here will just complicate things.

Anyways, everyone feel free to [flaming] my caveman interpretation.

Share this post


Link to post
Share on other sites
fguihen,

I would suggest that you take a look at the articles listed here at gamedev.net. There's quite a few, and one of them may be just what you're looking for, :):

Gamedev Articles on Matrices

I think some of the articles may be located offsite, at gamasutra.com. That site may require a free registration---highly recommended.

You might also look at the Game Developer's Conference archives, available online at:

Game Developer's Conference Archives

Look in the speaker slides and proceeding sections. You'll find lots of technical papers/presentations and there may be some very useful 3D math ones.

Share this post


Link to post
Share on other sites
You should consider enrolling for a foundation maths course. You need a strong grasp of why a matrix can be useful before you can usefully use it!

They are a way of performing simulteanous equations. You can buy really thick textbooks that explain only the uses of matrices.

Forunately (?) many API's attempt to shroud the more complex means of using matrices with methods such as D3DXMatrixRotation() etc.

Consider this:

[ 5 6 ] [ x ] [ 5 ]
[ ]x[ ] = [ ] is same as 5x + 6y = 5 AND 3x + 4y = 2
[ 3 4 ] [ y ] [ 2 ]


However in 3d transformations you can store essentially the coefficients of an equation which will transform one point at a time.

P-world = M x P-local
where M is a transformation matrix

will convert a point from local to world space.

You can combine your translation, scale and rotation (and others) into 1 matrix dramatically reducing the amount of computation.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!