Live data from Hacker News

Matrices can be your friends (2002)

sjbaker.org

61–70 of 115 posts

Re: Matrices can be your friends (2002)

#61

People must get taught math terribly if they think "I don't need to worry about piles of abstract math to understand a rotation, all I have to do is think about what happens to the XYZ axes under the matrix rotation". That is what you should learn in the math class! Anyone who has taken linear algebra should know that (1) a rotation is a linear operation, (2) the result of a linear operation is calculated with matrix…

> This guy makes it sound like he had to come up with these concepts from scratch, and it's some sort of pure visual genius rather than math. But... it's just math.

The problem with this kind of thinking is that it encourages the exact kind of teaching you disparage. It's very easy to get lost in the sauce of arbitrary notational choices that the underlying concepts end up completely lost. Before you know it, matrices are opaque self-justified atoms in an ecosystem rather than an arbitrary tabular shorthand. Mathematics is not a singular immutable dogma that dropped out of the sky as natural law, and rediscovery is the most powerful tool for understanding.

Re: Matrices can be your friends (2002)

#62

Earlier quoted context omitted.

> most programmers are visual thinkers I remember reading that there's a link between aphantasia (inability to visualize) and being on the spectrum. Being an armchair psychologist expert with decades of experience, I can say with absolute certainty that a lot of programmers are NOT visual thinkers.

Do you have anything I can read about that? I'm definitely on the spectrum and have whatever the opposite of aphantasia is, I can see things very clearly in my head

"In Experiment 2 we have shown that people with aphantasia report higher AQ scores (more traits associated with autism than controls), and fall more often within the range suggestive of autism (≥32)."

https://www.sciencedirect.com/science/article/abs/pii/S10538...

Re: Matrices can be your friends (2002)

#63

> Mathematicians like to see their matrices laid out on paper this way (with the array indices increasing down the columns instead of across the rows as a programmer would usually write them). Could a mathematician please confirm of disconfirm this? I think that different branches of mathematics have different rules about this, which is why careful writers make it explicit.

This is one of those things that's perennially annoying in computer graphics. Depending on the API you can have different conventions for:

- data layout (row-major vs. column major)

- pre-multiplication vs. post-multiplication of matrices

Switching either of these conventions results in a transposition of the data in memory, but knowing which one you're switching is important to getting the implementation of the math right.

And then on top of that for even more fun you have:

- Left- vs. right-handed coordinate systems

- Y-up or Z-up

- Winding order for inside/outside

There are lots of small parity things like this where you can get it right by accident but then have weird issues down the line if you aren't scrupulous. (I once had a very tedious time tracking down some inconsistencies in inside/outside determination in a production rendering system.)

Re: Matrices can be your friends (2002)

#64

People must get taught math terribly if they think "I don't need to worry about piles of abstract math to understand a rotation, all I have to do is think about what happens to the XYZ axes under the matrix rotation". That is what you should learn in the math class! Anyone who has taken linear algebra should know that (1) a rotation is a linear operation, (2) the result of a linear operation is calculated with matrix…

> Anyone who has taken linear algebra should know that [...]

My university level linear algebra class didn't touch practical applications at all, which was frustrating to me because I knew that it could be very useful to some background doing hobbyist game dev. I still wish I had a better understanding of the use cases for things like eigenvectors/values.

Re: Matrices can be your friends (2002)

#65
post #3

I don't think there's any mathematical reason to lay out the elements in memory that way. Sure given no context I would probably use i = row + n col as index, but it doesn't really matter much me. If I had to pick between a matrix being a row of vectors or a column of covectors, I'd pick the latter. And M[i][j] should be the element in row i column j, which is nonnegotiable.

This was answered in the article.

>> It is often fortunate that the OpenGL matrix array is laid out the way it is because it results in those three elements being consecutive in memory.

Re: Matrices can be your friends (2002)

#66

People must get taught math terribly if they think "I don't need to worry about piles of abstract math to understand a rotation, all I have to do is think about what happens to the XYZ axes under the matrix rotation". That is what you should learn in the math class! Anyone who has taken linear algebra should know that (1) a rotation is a linear operation, (2) the result of a linear operation is calculated with matrix…

I took a linear algebra class, as well as many others. It didn't work.

Most math classes I've taken granted me some kind of intuition for the subject material. Like I could understand the concept independent from the name of the thing.

In linear algebra, it was all a series of arbitrary facts without reason for existing. I memorized them for the final exam, and probably forgot them all the next day, as they weren't attached to anything in my mind.

"The inverse of the eigen-something is the determinant of the abelian".

It was just a list of facts like this to memorize by rote.

I passed the class with a decent grade I think. But I really understood nothing. At this point, I can't remember how to multiply matrices. Specifically do the rows go with the columns or do the columns go with the rows?

I don't know if there's something about linear algebra or I just didn't connect with the instructor. But I've taken a lot of other math classes, and usually been able to understand the subject material readily. Maybe linear algebra is different. It was completely impenetrable for me.

Re: Matrices can be your friends (2002)

#67
> What stops most novice graphics programmers from getting friendly with matrices is that they look like 16 utterly random numbers.

Wait until they see how physicists and chemists treat matrices! They will pine for the day when a transformation can be described by 16 numbers in a table.

Re: Matrices can be your friends (2002)

#68
For my fellow visual thinkers who might be looking for a linear algebra book that focuses more on developing the geometric intuition for stuff like this, rather than just pure numeric linear system solving, let me recommend:

"Practical Linear Algebra: A Geometry Toolbox" by Farin and Hansford.

Re: Matrices can be your friends (2002)

#69
Anecdote from someone does a lot of graphics programming. (Building a molecule viewer/editor):

I've only needed matrices exactly once, when building the engine. It does a few standard transforms (model view matrices etc).

The rest is all len-3 Vecs, and unit quaternions. You can use matrices for these, but I'm on team Vec+Quaternion!

Re: Matrices can be your friends (2002)

#70
post #31

Earlier quoted context omitted.

This is interesting because, to me, programing is a deeply visual activity. It feels like wandering around in a world of forms until I find the structures I need and actually writing out the code is mostly a formality.

I would describe my experience of it similarly, but wouldn't call it "visual thinking" in the sense meant in the article, where one uses actual imagery and visual-spatial reasoning. Indeed, I almost completely lack the ability to conjure mental imagery (aphantasia) and I've speculated it might be because a part of my visual cortex is given over to the pseudo-visual activity that seems to take place when I program. I'…

> Is your "wandering" of this sort of pseudo-visual nature, or do you see actual visual images that could be drawn?

They're like if the abstract machines you talk about in CS theory classes were physical objects.

For example, thinking about a data processing pipeline, I might see the different components performing transformations on messages flowing through it. I can focus on one component and think about how it take apart the message to extract the structure it's trying to manipulate, interacts with its local state, etc. If something is active and stateful it feels different than if it's just a plain piece of data. I run the machine through its motions to understand where the complexity is and where things could break, comparing different designs against each other.

I'm thinking about a data format, I think about the relationships between containers, headers, offsets between structures, etc, like pieces that I can move around to see how their relationships change and understand how it would work in practice.

It's more than an image that can be drawn because the pieces are in motion as they operate. It's the same kind of "material" that mathematical objects are made out of when I'm thinking about abstract math. It's immensely useful skill for doing my job, in designing systems.

I actually struggle a lot with translating the systems in my head into prose. To me, certain design decisions are completely obvious and wouldn't need to be stated, so when we all understand the product goals I often to neglect to explain why a certain thing works the way it does, because to me it's completely obvious how it's useful towards achieving the product goals. So that's something I have to actively put more effort into.

I also really struggled when I took a real linear algebra class, since it was taught in a very blackboardy "tabular" style which was harder for me to visualize. I was unfamiliar with it due to being used to thinking about matrices in the context of computer graphics and game engines.

Post reply on HN