• Create Account

## What objects do I use matrices for?

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

4 replies to this topic

### #1Slushy  Members

168
Like
0Likes
Like

Posted 08 November 2012 - 12:28 PM

So, I've been looking alot into matrices lately. I understand all the "math-parts" regarding multiplying, adding them together and all that stuff. What I can't seem to get a grasp of is when do I use them correctly? I know that they are very effective when it comes to camera's. But do I also use them for models?

So that I have a position vector and a rotation vector, load them into a Float buffer and do glLoadMatrix('floafbuffer'); for every model/object that I want to render aswell? Or do I not need to use matrices for theese stuff?

If so, what do I use them for? Only cameras?

Im using Java with OpenGL btw. (LWJGL)

EDIT: I accidentaly posted this in Math and Physics, I meant to post it in "For Beginners". So if any moderator sees this, could you please move it? Thanks!

Edited by Slushy, 08 November 2012 - 12:35 PM.

### #2Álvaro  Members

20235
Like
3Likes
Like

Posted 08 November 2012 - 01:14 PM

In the context of the graphics pipeline, matrices represent transformations to be applied to vectors, by multiplying the matrix by the vector (there is a choice as to whether you multiply matrices times column vectors or row vectors times matrices, but it's only a matter of convention). You can use them to put a model in the world (by mapping the model coordinates to world coordinates), or to map world coordinates to image coordinates (the camera), or to express the location of a bone with respect to its parent.

For completeness, symmetric square matrices are also used to represent quadratic forms, but there are probably limited uses for this in game development.

### #3Slushy  Members

168
Like
0Likes
Like

Posted 09 November 2012 - 04:12 PM

That is really helpful, thanks alot! I'll have to read up on some further stuff regarding world/local/image coordinates but thanks again!

Edited by Slushy, 09 November 2012 - 04:12 PM.

### #4Khatharr  Members

7659
Like
1Likes
Like

Posted 10 November 2012 - 01:54 PM

The three transforms:

World - Changes the vertices from local space to world space. This assigns a position/rotation/scale to the model in the world space. It can be thought of as placing an object in a room.
View - Changes the vertices from world space to 'camera' space. This essentially changes everything so that the camera is the origin. It can be thought of as positioning the camera to look at the object.
Projection - This is the weird one. The camera angle creates a sort of rectangular cone shape. In order to get pixel colors we want that to be a 3D rectangle. In other words we want the near plane of the frustum (the visible area) to have the same width and height of the far plane of the frustum. The result is that things nearer to the camera get stretched a bit so they look closer. Once this is done the graphics hardware can look in straight lines from the center of where each pixel maps to the near plane to the same x/y coordinate on the far plane and if there's an intersection then we fetch a color value for the point on the polygon where the intersection occurs.

Since these transforms can all be described as matrices they can all be multiplied to get a single matrix that can correctly perform all three steps on each vertex in the model.

Here's a Microsoft article that discusses it a bit:

http://msdn.microsof...9(v=vs.85).aspx

You could also use matrices or quaternions to implement complicated rotations in three dimensional space, such as for a flight simulator or spacecraft simulator where where you have to compound several angles/vectors together.

Edited by Khatharr, 10 November 2012 - 02:01 PM.

void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

### #5Slushy  Members

168
Like
0Likes
Like

Posted 10 November 2012 - 03:41 PM

The three transforms: ....

Wow, yet again. That is extremely helpful! I can't believe the help im getting out of this forum, greatly appreciated. Thanks again!

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.