# Thread: Explain Matrices to a 15 Year Old

1. ## Explain Matrices to a 15 Year Old

Can anybody here explain matrices to a 15 year old? I have done kramer's rule in math but thats about it. The way my computer graphics teacher explained glPushMatrix() and glPopMatrix() to me was that any rotations or translations done between them only affect whats drawn between them. However, now I'm running into lots of problems when drawing my terrain in my game. Like when I scroll the mouse wheel and it changes the camera's y position, it also changes the terrain's position. Does anybody have any ideas on what might be causing this? I push and pop the matrix before I draw the terrain.

What exactly is this "rotation matrix"? Can anybody put it into terms I can understand? Thanks

2. ## Re: Explain Matrices to a 15 Year Old

Matrices represent a linear mapping of a system of equations. In other words any system of equations returning distinct results can produce a matrix of the same rank.

What you need is to read an intro to algebra.

3. ## Re: Explain Matrices to a 15 Year Old

Of course when you change the camera position the land scape will change to reflect it.

Remember OpenGL does not move the camera, you move the world around it to look like camera is moving.

You must keep this in mind this when drawing your world.

Originally posted by 31337:
Can anybody here explain matrices to a 15 year old? I have done kramer's rule in math but thats about it. The way my computer graphics teacher explained glPushMatrix() and glPopMatrix() to me was that any rotations or translations done between them only affect whats drawn between them. However, now I'm running into lots of problems when drawing my terrain in my game. Like when I scroll the mouse wheel and it changes the camera's y position, it also changes the terrain's position. Does anybody have any ideas on what might be causing this? I push and pop the matrix before I draw the terrain.

What exactly is this "rotation matrix"? Can anybody put it into terms I can understand? Thanks

4. ## Re: Explain Matrices to a 15 Year Old

How do these matrices work into opengl though? I don't see the relation

5. ## Re: Explain Matrices to a 15 Year Old

Arnt the matrix setting up OpenGl? And OpenGl uses them. You don't need to know a lot about them. I know that when you want to rotate something a "rotation matix is mulitpled with the transformation matrix" or the modal matix. Like glRotatef(). The rendering is created though those matrixs. But yer how that happen I have know idear.

6. ## Re: Explain Matrices to a 15 Year Old

I do not know the insights of opengl as I didn't develop it. But my bet is that every vertex (being in Eucledian space) is multiplied by a transformation matrix that is generated by glRotatef, Translatef etc.
When you reset the matrix it simply makes an identity matrix.

Same thing is done for camera (perspective, orthographic, para-perspective) projections in projective and affine spaces. Basically everything in geometry (hence OpenGL) is driven by matrices.

7. ## Re: Explain Matrices to a 15 Year Old

This way help-

Shows how a matrix is used to transform a point in 3D space.

outx = mtx[0][0]*pntx + mtx[1][0]*pnty + mtx[2][0]*pntz + mtx[3][0];
outy = mtx[0][1]*pntx + mtx[1][1]*pnty + mtx[2][1]*pntz + mtx[3][1];
outz = mtx[0][2]*pntx + mtx[1][2]*pnty + mtx[2][2]*pntz + mtx[3][2];

Matrixes are difficult to understand but
much easier than getting someone to buy you
beer outside the 7-11

8. ## Re: Explain Matrices to a 15 Year Old

In the simpless form, the matrix is applied to each vertex point.

example we tell the matrix to do a translate on -5,0,0, every X vertex drawn after the translate command will be subtracted by -5.

Originally posted by 31337:
How do these matrices work into opengl though? I don't see the relation

9. ## Re: Explain Matrices to a 15 Year Old

Eucledian space what that? superfical 3d space like x,y,z in data.

10. ## Re: Explain Matrices to a 15 Year Old

All Opengl basically does is rasterize(draw) primitives(like tris etc.) which are defined by points.In order to define a point of course you need a coordinate system.Say our initial coord. system(with the identity modelview matrix) where we have defined a quad looks like this:

Code :
```  ^
|
| x--x
| |  |
| x--x
|
--+---------->
|```
Now say we load a rotation matrix instead of an identity and then draw the same quad.The quad vertices' coords. will be the same but they'll be multiplied by the modelview(rotation) matrix (among others,more on that later) which will cause a rotation of the coord. system.Something like that:

Code :
```  ^       x
\     /\
\  x/  x   /
\  \  /  /
\  x/  /
\    /
\  /
\/
/\```
(I know it sucks but it's the best I can do with ascii art)

Now when viewed relatively to the new coordinate systm the quad is exactly the same as in the first figuer but when viewed relatively to the initial coord. system the quad has been rotated.It's in 2D here due to technical limitiation but the same goes for 3d.
The modelviewm matrix maps vertices from world space to object space.As they go down the rendering pipeline vertices are mapped to clip space and device space by the projection and viewport matrices.
Read the initial chapters of the Red book(the online old version will do fine) and so a google search (www.google.com).There's nothing hard about matrices.

[This message has been edited by zen (edited 11-23-2002).]

Page 1 of 2 12 Last

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•