Saturday, August 2, 2008

Linear Algebra - month 3

Everybody is familiar with Algebra, but a common question about Linear Algebra is simply "What is Linear Algebra?" Here is the definition according to wikipedia - "Linear algebra is the branch of mathematics concerned with the study of vectors, vector spaces (also called linear spaces), linear maps (also called linear transformations), and systems of linear equations. Vector spaces are a central theme in modern mathematics; thus, linear algebra is widely used in both abstract algebra and functional analysis. Linear algebra also has a concrete representation in analytic geometry and it is generalized in operator theory. It has extensive applications in the natural sciences and the social sciences, since nonlinear models can often be approximated by linear ones."

At Full Sail we focus mainly on vectors algebra (adding, subtracting, dot-products, projections, and so on) and how it applies to games. We really leverage the dot product its amazing how much it can do for you, being a math geek I get excited just thinking about it! We also do a lot with linear transformations (rotation, translation, and scaling matrices) we do a lot of matrix computations. And finally we use quaternions to do rotations, which everybody is scared of but are actually way easier to deal with if you ask me and much safer because they avoid what is known as a Gimbal Lock

The main theme of the class is the mechanics, everything you need to manipulate vectors and matrices. The secondary topic is how to use them in video games, but you are only tested on the mechanics. So basically you can get away without learning much, mechanics are necessary but they don't mean much unless you know how to use Linear Algebra as a tool. So if you go through this class you take notes, you pay attention to the usage of these tools (because it is thoroughly covered) and you learn not only how do the mechanics but how to make the math work for you, then you can do some really cool things! And that's the key to this class, the information can seem complicated and convoluted at times but don't quit taking notes or lose focus. The things you don't understand look up online or in the book to learn more about them (I have this book Essential Mathematics for Computer Graphics by John Vince that turned out to be a good supplement).

The Instructor (Richard Bahin) is an interesting guy, very animated, very good with math, and very hard to understand. He is from the Ivory Coast and has a thick french accent. It took me a while to be able to catch most of what he was saying. The actual math I could follow because it was math but the accent was a definite barrier to understanding the context. Over time though you learn to interpret bahin speak then things go pretty well.

So the math is a powerful tool and Bahin drives this home at every class, he always says video game programmers who are afraid of math are not video game programmers. Some people would debate that but I believe he is right, using the techniques from class I was able to do some pretty cool things that would have been immensely complicated without linear algebra, with it they became trivial.

I started a library of math functions for vectors and matrices, I've been using my library to put the math to practice and reinforce the what I've been learning in this class, programming, and anything to come really. I'm constantly tweaking and adding new functionality and sometimes re-writing pieces of the library. Just to demonstrate the power of the math I have used some very primitive Win32 API draw functions to draw a triangle then using the math I make it look like its in 3D. Now the built in draw functions are only meant to be for 2D but it was trivial to turn this into 3D with the power of quaternions.

Rotation example (triangle rotation on an xyz axis, axis = (1,1,1)
Rotation

Same thing with a cool effect!
Rotation2

We also learned about collision detection in this class. Again, we were not tested on this but obviously collision detection is very important, and hard to implement I might add. Here is another example, its not pretty but that's not the point, this is just an example of what I have been able to accomplish using some of the math. So far the response to the collision is not smart I'm just trying to detect a collision then send the colliding object off in some other direction, no physics involved (yet) so its kinda interesting what happens to the balls when they are skewered by the ray.

Some collision Detection (this uses tons of vector math)
CollisionTest

Again all these examples were just some of the stuff I have been able to do with the math. Eventually we will cover this stuff in class but I just want to get a handle on it as soon as possible because to me the math is the most important part. And that's about it so far for linear algebra, next posts are for for Programming 3 and Physics.

6 comments:

Greg R. said...

You've taken your first steps into a larger...um a larger.. Dang it, forgot my lines.


For real though, good work.

Anonymous said...

I know how to drive a tank... what do ya think about that?

~kristi said...

Ok, I just want pics of Tammy, Charlie, you and the beach, maybe Mickey or Minnie!

Ben said...

Cool stuff! Oh yeah...your a nerd ;)

Anonymous said...

Look Tim, here on earth we don't know what your talking about. Can your break it down Barney style for us?

Tom Richards, aka OldWeirdDad said...

I'm so glad you put in the link to "Gimbal Lock". I was tripped up a little on that one. But once I read the explanation on the link - bamo! - perfectly understandable. Although, just for the record, I am familiar with JOHHNY GIMBLE, the fiddle player with Bob Wills and the Texas Playboys.

I agree with Kristi - we need pictures of everyone. Take pictures of the campus, your classes, etc.

More brandy! More brandy!