# What exactly is a matrix?

## Recommended Posts

I am currently using the OpenGL and OpenSceneGraph API's to do some uni work and although i am still just learn the basics such as composing primitives, GL states and lighting there has been something bugging me for a while now. When i have to rotate or translate objects the documentation that i am using always refers to the matrix, I hate to sound stupid but what actually is a, or the matrix? So, for people who actually have an understanding of computer graphics, how would you define what the matrix actually is? Thanks for any input and apologies if my question is confusing :-)

##### Share on other sites
http://en.wikipedia.org/wiki/Matrix_(mathematics)

##### Share on other sites
While a definite answer to your question could fill one thousand textbooks, this might help to get you started:

http://www.sjbaker.org/steve/omniv/matrices_can_be_your_friends.html

What you really want to look up is an introduction to "Linear Algebra", this entire field of mathematics is devoted to study of matrices.

##### Share on other sites
Nobody can be told what matrix is....

PS: Sorry

##### Share on other sites
It's like a Sudoku.

##### Share on other sites
Symbolically, a matrix is just a way to hold the coefficients of a solution of m equations involving n unknowns (m x n matrix).

However, in linear algebra, we can also define a matrix to be a list of n vectors in R^n space.

Ex:
[ 1 2 3 ]
[ 3 1 7 ]
[ 2 9 6 ]

Can be understood as the coefficient matrix of a system of equations or as the three vectors, a1, a2, and a3, where a1 is the first column, a2 the second, and a3 the third.

There are a number of operations we can do with matrices, but these only make sense if you understand that as a system of vectors, a matrix is a transformation of the vector you are multiplying from R^n space to R^m space.

In graphics programming, we typically use a 4 x 4 matrix, which means when we multiply an R^4 vector by a matrix, a transformation occurs, producing a vector also in R^4 space.

Ex: A(m x n matrix) * b(R^n vector) = c(R^m vector)

If you consider matrices transformations, then we can describe the multiplication of matrices as the composition of transformations, just like when we compose functions. And just like the composition of functions, order matters.

Ex: g(f(x)) != f(g(x))
AB != BA (generally)

In graphics programming matrices are primarily used as transformations (or functions) that take a vector and produce a vector. By multiplying (composing) matrices, we can reduce the number of multiplications each vector needs.

For a more complete definition, Google is your friend, but a text would be better. I purchased a text on linear algebra at Half Price Book Store for \$4.99 (no joke) for my class this semester.

##### Share on other sites
Quote:
 Original post by AntheusNobody can be told what matrix is....

My thoughts exactly [grin]

To maintain some semblance of useful posting, I personally found this math primer a nice accessible starting point on what vertices and matrices are and how they work.

##### Share on other sites
Quote:
 Original post by karwostsWhat you really want to look up is an introduction to "Linear Algebra", this entire field of mathematics is devoted to study of matrices.

Linear Algebra also encompasses systems of linear equations, et al. Matrices are, as far as my understanding goes, just a helpful data structure/notation.

Unless I'm totally studying the wrong thing in preparation for my mathematics units at uni. >_>

##### Share on other sites
Quote:
 Original post by FenrisulvurLinear Algebra also encompasses systems of linear equations, et al. Matrices are, as far as my understanding goes, just a helpful data structure/notation.Unless I'm totally studying the wrong thing in preparation for my mathematics units at uni. >_>

No worries, at least my uni course back in the day started with systems of linear equations after the preliminaries. Later on it tapered off into vagueness with vector spaces, which is the part heavily used in computer graphics.

For an accurate treatise check out the link above, but the basic idea is that a matrix can transform vectors from one vector space to another. So you can use a matrix to stick your model vertices in a coordinate system that is for example translated or rotated wrt the base coordinate system (typically called world space).

##### Share on other sites
It's just a grid, that's all it means. It has many complex uses but it's literally just a grid of numbers, 2 dimensional (width and height).

##### Share on other sites
Quote:
 Original post by DanX2002It's just a grid, that's all it means. It has many complex uses but it's literally just a grid of numbers, 2 dimensional (width and height).

That's true, but it doesn't explain why they are important. What makes matrices important is that they represent linear transformations between vector spaces of finite dimension, which in turn can be used to represent affine and projective transforms.

Matrices have other purposes (they represent quadratic forms, dense weighted graphs...), but those are less relevant for graphics programming.

##### Share on other sites
You have to see it for yourself.......

Jokes aside, the simple definition is an array with rows and collumns that holds data. Now there is more than that to a matrix (or the Matrix.....) but that's what it is basically.

Watch out for the agents!
lol

##### Share on other sites
AS was said before a matrix is just a 2D group of numbers. Just as a Vector is a 1D group of numbers and a Scaler is a 0D number. For instance:

6 is a Scaler as well as a Vector1 and a 1x1 Matrix

(2,3,5) is a Vector3 as well as a 1x3 Matrix

(5,2,7)
(2,4,6)
(4,7,8) is is 3x3 Matrix but it can also be broken down into 9 vertical and horizontal vectors (5,2,7), (2,4,6), (4,7,8), (5,2,4), (2,4,7), (7,6,8)

In the end it's the meaning that we give to these groups of numbers that is the important thing. E.G the Scalar could represent a speed. the Vector can represent a point in 3D space or a vilocity and a 3x3 Matrix can represent a rotation of a point in 3D space.

##### Share on other sites
Just to clarify mathematically, a matrix can be any number of dimensions. In aerospace we often work in 6D representing the 6 degrees of freedom X-axis, Y-axis, Z-axis, and rotation about the X, Y, Z axes.

Just to give a visual example, a 3D matrix (3x3x2) would look like this:

1 2 3
4 5 6
7 8 9

9 8 7
6 5 4
3 2 1

The numbers above are one matrix, not 2. Just imagine they are stacked on top of each other, ie - 3D.

##### Share on other sites
Quote:
 Original post by PsycloneJust to clarify mathematically, a matrix can be any number of dimensions. In aerospace we often work in 6D representing the 6 degrees of freedom X-axis, Y-axis, Z-axis, and rotation about the X, Y, Z axes. Just to give a visual example, a 3D matrix (3x3x2) would look like this: 1 2 34 5 67 8 9 9 8 76 5 43 2 1 The numbers above are one matrix, not 2. Just imagine they are stacked on top of each other, ie - 3D.

Wouldn't that just be an array of 2 matrices? Makes more sense to store 6D data as columns in a 6xN matrix.

##### Share on other sites
Quote:
 Original post by PsycloneJust to clarify mathematically, a matrix can be any number of dimensions. In aerospace we often work in 6D representing the 6 degrees of freedom X-axis, Y-axis, Z-axis, and rotation about the X, Y, Z axes.

Yes, 6x6 matrices are matrices.

Quote:
 Just to give a visual example, a 3D matrix (3x3x2) would look like this: 1 2 34 5 67 8 9 9 8 76 5 43 2 1 The numbers above are one matrix, not 2. Just imagine they are stacked on top of each other, ie - 3D.

That's no matrix. The generalization you are using here is called a tensor. Please, don't spread misinformation.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628390
• Total Posts
2982411

• 10
• 9
• 19
• 24
• 11