#### Archived

This topic is now archived and is closed to further replies.

# What are Matrices

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

## Recommended Posts

I''m currently going through the book ''Role Playing Games with DirectX'' and I''m stuck in the section about matrices. What are they for? And also what a transformations for. Are they for converting coordinates to world coords? thanks in advance.

##### Share on other sites
If you use the search engine and have a look at the article section and google you will find a lot about them

But here is a short explanation:

Matrices are numbers that are ordered in row/column order

For example:
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
This is called the Identity matrix. Everything multiplied with this matrix will not change it..

But you can offcourse put other numbers in it. Say you add x_trans y_trans and z_trans to the bottom row and multiply a point against the matrix it will be transformed:
x + x_trans, y + y_trans,z + z_trans.

You can also use matrices for rotation. You then need to alter other rows/columns with your sin/cos functions.

The great advantage of using matrices is that you can combine several translations/rotations in one matrix. Say you''ve got a local to world, world to camere, camera to perspective transform you could do all those transforms one by one on each point but you can also combine them. If you first multiply all the different matrices together you have 1 matrix that has all the rotations/translations that are necessary to go with 1 multiplication from local to perspective.

Go and search the internet for tutorials that teach you how to add/substract/multiply matrices and learn to love them

Also.. do you already know what vectors are and how to use them? Matrices and vectors should are the things every game programmer needs to know

##### Share on other sites
From a maths book (always advisable that your bookshelf should have one if you intend programming 3d stuff):

"A matrix is a set of numbers [...] arranged in a rectangular array of rows and columns. The structure of a matrix makes it easy to assemble and work with certain kinds of mathematical data. The coefficients of a set of simultaneous linear equations or the coordinates of a point can be written as a matrix, for example. However, a matrix is not just a tool to organize data. One matrix can operate on another matrix to change the data in some way. For example, we can use matrices to solve complex systems of equations, to represent geometric objects in computer databases, and to perform geometric transformations, such as translation, rotation and scaling."

So basically they''re for all sorts of things and simply a nice way of collecting a bunch of maths operations into a well defined place.

Coordinate transformations are anything that changes a coordinate in some way - rotating it, changing its size, moving it, skewing it etc.

Converting object "space" coordinates into world space coordinates is simply applying the transformations (scaling, rotation, translation etc) to those coordinates. A matrix can hold more than one transformation. The process of combining matrices to form a single one that holds all the operations is "concatenation" (matrix multiplication).

--
Simon O''Connor
3D Game Programmer &
Microsoft DirectX MVP

##### Share on other sites
Scheermesje
''Also.. do you already know what vectors are and how to use them? Matrices and vectors should are the things every game programmer needs to know''

Nope.

##### Share on other sites
There are so many 3D primer articles hosted by this very site. Query for the related words (vector, rotation, transformation, matrix, blah) here: Articles & Resources. You did the right thing by asking

1. 1
2. 2
Rutin
20
3. 3
4. 4
frob
15
5. 5

• 10
• 9
• 13
• 9
• 33
• ### Forum Statistics

• Total Topics
632592
• Total Posts
3007289

×