Hacker News new | ask | show | jobs
by archgoon 5439 days ago
So... when people say "Deep Understanding of Linear Algebra", is it really anything more than being comfortable with the idea that rotations, and perspective transformations, can be represented as matrices? Any 3D graphics programmers (not necessarily for games) who can highlight the main aspects of Linear Algebra that they use?
1 comments

Dot product.

Here's a random list of thoughts, speaking as a graphics and game programmer:

First, you hardly ever have to even think about "perspective transformation". Put it out of your mind until you're ready to attempt acquiring advanced knowledge, because it will just confuse and therefore hinder you.

Second, a transformation is typically a 4x4 matrix. It looks like this:

  Xx Yx Zx Px
  Xy Yy Zy Py
  Xz Yz Zz Pz
  0  0  0  1
In this case, "P" is the translation ("how much the matrix will move the input").

X, Y, and Z are "right", "up", and "forward" directions, respectively.

That is, imagine yourself sitting in your chair. Your comupter table defines absolute right (1,0,0) up (0,1,0) and forward (0,0,1).

Now imagine a blue arrow coming out of your chest towards your monitor. That's your Z axis. Imagine a green arrow coming out of your head, pointed at the ceiling. That's your Y axis. And now stick your right arm straight out and color it red. That's your X axis.

Now rotate to the left 45 degrees. Then scoot two meters backwards ("backwards" as in "opposite the direction you're currently facing", NOT "away from your computer desk"). Imagine the arrows rotating as you do this. Now figure out the exact numbers for those arrows (vectors). Plug those into X, Y, and Z columns of the matrix. Plug (0,0,-2) into the P column of the matrix. Congrats, you've built a transform that "rotates an object to the left 45 degrees, then scoots it back two meters".

Note that the above assumes a left handed coordinate system, with Y axis being 'up'. Which is the most natural IMO.

Lastly, dot product is the most important tool you could possibly want to understand. It's so versatile. You want to figure out the closest point on a line to point P?

  dot( (P - line.start), normalize(line.end - line.start) )
... is the distance along the line of the closest point to P.

It's a projection. It "projects" a point onto a basis. (I know a lot of mathematicians are probably screaming at their monitors at me right now, but foo on that. This is one of the most useful ways to think about dot products with respect to game/graphics programming, which is what we're talking about.)

Also, if you want to impress any interviewer who asks you about dot product, remember this phrase: "The dot product of two normalized vectors is the cosine of the angle between them." ... But you should really also understand that phrase. =)