What do the values in matrices represent?

A few weeks ago I’ve seen a tweet from @machin3io where he was enthousiastic about matrices. Weeks later I was still curious what a matrix actually is. So I watched a (wrong?) tutorial which started to show an Excel table, removed the headers, (so we see only the data) and explained that that in fact was a matrix.

I guess that was the worst entry there is, because after watching more than 20 videos about matrices I still have no clue what the numbers represent (just any numbers, vectors, dimensions?). All videos start by explaining that a matrix is like an array that has rows and columns, and next lessons you see about translate them, do subtractions, multiplications with one number, multiplication with another matrix, etc.

It all looks interesting like below, but have no clue what it is or what the use case is:
matrices
import mathutils

Because I thought intuitively you can’t multiply an excel table with another table that has different rows and colums. But as you see below, it works:


My inuition said: how is it possible to multiply the first excel sheet with the second, the Jan, Berta, Hank and the day’s numbers will be scrambled.

Now I check it, I see it actually works,
matrixSolution

Rest now, that I think of a use-case: So I can multiply (keep ratio’s) a set of numbers (locRotScale?) with another set of numbers (factors)?. And each set doesn’t need to have the same amount of numbers. Is that the idea?

Or what is the use case of matrices (mathutils)?

I have been waging some of the same battles for some time, trying to get an idea what the heck it is all about, and I can only say that there is no understanding it without just putting your nose to the grindstone and learning Linear Algebra. I am currently taking a Udemy course Complete Linear Algebra: Theory and Implementation in Code. Taught by Mike X. Cohen, Neuroscientist, would definitely recommend that, but here are some other links I have discovered.

I have been watching videos, reading, using Python to calculate dot products, cross products, etc. I think that the only way to really get it is to keep at it until you understand each part of it. With me, I am the same way, I have to understand the what and the why, otherwise it is a waste of time.

3 Likes

We are in a very similar boat it seems. I started with a course Python and Machine Learning & data science by Jose Portilla. Then I found out very soon that I needed first to understand linear algebra. So then I got the course you have as well: Complete linear…in code (awesome!). Also that was a bit hard to follow so I got Linear Algebra 40+ hours of Tutorials which was a bit to dry for me. So I tried a few others (it was sales on Udemy) and at the end I bought 12 courses related to python, data science and algebra which I practice with quite a few hours in a day.

I think once I understand it, I will explain it others, but then with more visualisations and short animations and show use cases. Rather then just explaining the rules and exceptions etc.

Thanks for the links, I think that dot product, cross product will be a good entry point for me now.

1 Like

Ohh, wow, that video shows me exactly what I needed to know. In just 4 minutes (versus the 4 hours I watched from the rather dry explanation of matrices).

1 Like

best explanation I know of:

1 Like

That’s a good playlist for me. I mainly learn by visuals, understand it then experiment. Nowadays it’s a matter of finding good tutorials it seems, rather than the dry ones we had in school years ago.
I guess 30 years ago teachers were not able to teach like this.
Good stuff!

1 Like

3bue1Brown is a god when it comes to explaining scary math as if it was nothing.

1 Like

Blender makes use of OpenGL matrices so it’s pretty much like this:

  • the top 3x3 values represent the rotation
  • the left-top right-bottom diagonal represents the scaling and it’s overlapping (multiplied with) the rotation
  • the 4th column is the translation (position)
    This may sound complicated at first, but it’s just simple algebra (mults, divs, adds and subs) so don’t get scared by the way it looks. Computing rotations is a bit harder using some trigonometry, but there are special formulas about it that you can just follow so it’s rather easy.

When it comes to rotations, quaternions are better, but that’s another monster story :smiley: … Matrix multiplication is kinda the only operation you will ever need. Matrices are used because they can store so much data in one single block.

More about matrices here:

Well, in the context of computer graphics it’s not only the matrices you need to understand, but also the concept of homogeneous coordinates. This is when hearing it first a very weird thing, but it explains why the matrices in your screenshot are 4x4 instead of 3x3 although we work in 3-dimensional space. Unfortunately I don’t have any links, but googling should find you some explanations.

Well I wouldn’t explain it like this. If you e.g. rotate around 90 degrees, your scaling factors move off the diagonal. Here’s how I look at the parts of the matrix:

  • The 3x3 part of the top left corner contains all the linear parts of the transformation. That includes rotation, shearing, scaling.
  • The scaling factors are the lengths of the first the 3-dimensional column vectors.
  • The 4th column contains the translation vector
  • The 4th row could contain projective transformations, but usually is 0 0 0 1
1 Like

Do you have a screenshot of that matrix? I cannot visualise myself a top 3x3 values, 4th column, and a left-top right-bottom diagonal.

Update: oh, you mean the matrices in my first screenshot from mathutils?
So the top 3x3, in the 4x4 matrix. Then the last row and column, and diagonal of the 4x4 matrix?

I see that @Blutag included a link, and there I see the homogenous coordinates mentioned:
homogenousCoordinates

To what matrix are you refering to? Is that the matrices we see when we use mathutils, like in my first screenshot?

The last row is the w component. Check the link I gave you, 0 is for direction, 1 for position.

All matrices used for 3D are like that, including in game engines, that is 4x4 with the structure I mentioned. There is also the DirectX standard where the matrix is transposed (each row becomes a column, so the position is on the bottom row, unlike OpenGL where it’s on the last column)

But as you see in the picture you just posted, each element uses a matrix. So there is a matrix for model, one for camera (view matrix), and one for camera lens/perspective (projection matrix). They are all combined (multiplied) during rendering. There may be additional matrices for viewport display, but they are not of much interest.

1 Like

To sum up visually its like this then:


Source: https://sinestesia.co/blog/tutorials/python-cube-matrices/
And that for each element: model, camera, projection, and multiplied during rendering.
Correct?

2 Likes

Yep, that’s a very nice picture!
Edit: Actually the projection matrix is a completely different beast, you will probably never have to deal with it though, you can check it here:

1 Like