The new forums will be named Coin Return (based on the most recent vote)! You can check on the status and timeline of the transition to the new forums here.
Please vote in the Forum Structure Poll. Polling will close at 2PM EST on January 21, 2025.

Linear algebra...

DisrupterDisrupter Registered User regular
edited February 2011 in Help / Advice Forum
Linear algebra was the last math class I had in college. I did well at first when it came to basic matrix transformations and what not, but I didnt need the credit to graduate and eventually I dropped the course.

I could tell this was the one math class I might find a use for one day...curse me.

So Im trying to learn some game programming using XNA and of course, these concepts are pretty basic starting blocks here.

So, whats the best way to learn these concepts. Like, I sort of get them, but its hazy. So is there a good way to learn the basics to get a bit of a foundation? I read wikipedia and stuff but my brain is having trouble grasping them. I swear, all these tests in the world can claim Im good at math, and...I promise im not! Please help :)

Either pointing me to tutorials or breaking down the following concepts simply for me would help:

Transformation Matrix
Projection Matrix
View Matrix
Rotation Matrix

From what I think I understand, Projection and Rotation matrices are TYPES of transformation matrices? Rotation simply does what youd expect, rotate the matrix by a certain degree. Projection moves the matrix along a plane?

Am I sort of getting the concepts or am I way off?

I have no clue what a view matrix is.

616610-1.png
Disrupter on

Posts

  • tehmarkentehmarken BrooklynRegistered User regular
    edited February 2011
    Despite that I have a mutlidisc. degree that is half mathematics, I don't know much about matrices =\ I only took one course on matrices, and it was mainly in the practical application of them for solving engineering problems.

    I've never heard of a view matrix either =\

    http://reference.wolfram.com/mathematica/ref/ViewMatrix.html

    But apparently it's something specific to 3D graphics! So that makes me feel a bit better at least. I imagine what you'll be using are more program oriented matrices than pure algebraic matrices.

    tehmarken on
  • SavantSavant Simply Barbaric Registered User regular
    edited February 2011
    Yeah, that stuff is probably dealing with computer graphics rather than pure linear algebra. For a lot of the graphical computation and transformations the computers use matrix multiplication. These are 4 by 4 matricies since some of the necessary 3 dimensional actions cannot be handled solely with 3 by 3 matrix multiplication. So say if you wanted to draw a cube somewhere, you'd have a series of matrix transformations multiplied together to get the final transformation and you'd have the drawing primatives go from there.

    You are probably going to want to read up some tutorials about computer graphics to learn what that stuff means, perhaps something about OpenGL or DirectX to learn the basics. Some of this can get pretty low level however, and you might not need to directly work with the matrices rather than just have some understanding of how the system works so you can have it do what you want to.

    Savant on
  • MKRMKR Registered User regular
    edited February 2011
    Trying to use wikipedia to learn a math concept is like using a textbook to learn a math concept. It'll only end in tears.

    It's dangerous to go alone. Take this.

    Ctrl+F (or the search box on the site) to find specific things.

    MKR on
  • DisrupterDisrupter Registered User regular
    edited February 2011
    I have never heard of this Khan Academy before. But the fact that i am watching a you tube video breaking down what a matrix is for me makes me think this will walk me through enough to start getting the concepts. It seems to start pretty basic, so I should be able to follow since I did take a class on this stuff before...

    Thanks! Hopefully I'll be up to snuff in no time!

    Disrupter on
    616610-1.png
  • MKRMKR Registered User regular
    edited February 2011
    Disrupter wrote: »
    I have never heard of this Khan Academy before. But the fact that i am watching a you tube video breaking down what a matrix is for me makes me think this will walk me through enough to start getting the concepts. It seems to start pretty basic, so I should be able to follow since I did take a class on this stuff before...

    Thanks! Hopefully I'll be up to snuff in no time!

    PatrickJMT and Khan Academy got me through college algebra with a near B after a lifetime of crippling math phobia.

    I use algebra in my life all the time now. :rotate:

    MKR on
  • BowenBowen Sup? Registered User regular
    edited February 2011
    +1 to that link, gonna teach myself some biologies.

    Bowen on
  • strakha_7strakha_7 Registered User regular
    edited February 2011
    Your approach to these matrices is a bit off. Think of a "rotation matrix" as something that applies a certain rotation to an object that the matrix is applied to. Same for projection and transformation matrices.

    I don't know what a view matrix is, but it might be the relevant identity matrix so that your graphic engine can create what the image/object you're operating on looks like.

    Wolfram and Khan are really what you need, and they've been linked. Just make sure you understand the first point in this post, that matrices act on objects to create transformations of the initial object (set of values). Matrices themselves do not rotate, or translate, or anything.

    strakha_7 on
    Want a signature? Find a post by ElJeffe and quote a random sentence!
    ElJeffe wrote: »
    Zero tolerance policies are almost invariably terrible.

    One might say I have zero tolerance for them.
  • DisrupterDisrupter Registered User regular
    edited February 2011
    Hmm, mind clearifying.

    I do not quite understand the difference between a matrix acting on an object to create a transformation or the matrix transforming the object.

    Lets say we have a rotation matrix.

    We multiply that matrix by a vector and then the result is that vector, rotated by the angle specified by the matrix right?

    Disrupter on
    616610-1.png
  • SavantSavant Simply Barbaric Registered User regular
    edited February 2011
    Disrupter wrote: »
    Hmm, mind clearifying.

    I do not quite understand the difference between a matrix acting on an object to create a transformation or the matrix transforming the object.

    Lets say we have a rotation matrix.

    We multiply that matrix by a vector and then the result is that vector, rotated by the angle specified by the matrix right?

    You might want to read the wikipedia article on Rasterisation, as it provides a very basic overview of how some of this matrix math is commonly used in computer graphics.

    But the basic idea is you have a series of matrices multiplied together to transform the vectors and vertices so the drawing primatives can convert your scene properly onto your output, like your monitor. So you want to draw some triangles to make some sort of object, you'll have a series of matrices to scale, translate, and/or rotate it into the proper position and shape, and multiply them together with the matrices you need to project this, potentially using perspective, to your 2D output surface.

    The actual multiplying of matrices together and drawing of your primitives like triangles is handled at the low level by the graphics library and the graphics hardware, but you need to have your software call the functions to make sure that the correct matrices are built and applied in the right order so it actually draws what you want it to where you want it to.

    The different matrices that you are asking about are the matrices that do the different sorts of transformations you need in order to properly construct a scene.

    Savant on
  • DisrupterDisrupter Registered User regular
    edited February 2011
    Yeah, I suppose actually knowing the math behind them isnt really needed at this point, Maybe years ago, but likely the library will be doing all that...

    Still, its something id like to have a firm understanding on rather then just calling a model.rotate() function and wash my hands of it. thanks for the link, Ill check it out.

    Disrupter on
    616610-1.png
  • MKRMKR Registered User regular
    edited February 2011
    There will come a day when you find a critical bug in a library and you have to either rewrite it from scratch or fix it.

    MS frameworks are solid for the most part, but it could happen.

    MKR on
  • SavantSavant Simply Barbaric Registered User regular
    edited February 2011
    Disrupter wrote: »
    Yeah, I suppose actually knowing the math behind them isnt really needed at this point, Maybe years ago, but likely the library will be doing all that...

    Still, its something id like to have a firm understanding on rather then just calling a model.rotate() function and wash my hands of it. thanks for the link, Ill check it out.

    Well, you want to have some understanding of the math so you know what is happening when you call those functions, and when your program inevitably runs into problems and bugs you have a clue what sort of things you need to do to fix it.

    However, a lot of the stuff you are asking about is math specific to computer graphics and graphical applications of linear algebra rather than just being linear algebra in general, so if you want to dig deeper that is where you should focus your efforts.

    Savant on
  • DisrupterDisrupter Registered User regular
    edited February 2011
    Gotcha. Its just hard to jump into the specific graphical applications and really understand what is going on. I tried doing so. And im left going "yeah..I...kinda understand what we are doing with the camera there..." but without going back to the basics Im sort of faux following. Like, I get it in theory, but I get it the same way my wife would get it if I explained it to her.

    Which...isnt good enough :)

    Disrupter on
    616610-1.png
  • superchewiesuperchewie Registered User regular
    edited February 2011
    Here's a basic rundown of the matrices you asked about. It's been a few years since I took graphics, so you should probably use other sources to verify this.

    Transformation Matrix
    For your purposes right this moment, think of a vector as a point in space. Mulitplying by a transformation matrix transforms (moves) that point (or more commonly, a collection of points, i.e. a model). Transformation is a general term which covers several more specific types of matrices:

    translate - move in the x, y, or z direction (think dragging a window)
    scale - shrink/enlarge
    rotate - rotate about the origin by a certain angle
    shear - kind of like slanting. If you have a square, then slant the left and right sides in one direction, you've sheared it.
    Wikepdia has a few others too if you'd like to see some others.

    Projection Matrix
    Either perspective or othorgraphic. Perspective if you want depth, orthographic if you don't. I don't remember how these are exactly defined and what happens when you change some of their values. That's all I ever needed to know, though.

    View Matrix
    Goes from world to screen coordinates. Screen coordinates usually have (0, 0) as the top left, x+ is to the right, and y+ is down. That kind of system doesn't make sense for an infinite 3D space, though. What would top left be in the world? (10, 5, -3) in the world is some point, and if your camera is looking at it (from some arbitrary position), it needs some way to figure out where on your screen to put it. The view matrix does that.

    Rotation Matrix
    As I mentioned above, this is a kind of transfromation matrix. It rotates by the given angle in whichever axes about the origin. So if you wanted to rotate an object in place you'd have to translate it to the origin, rotate it, then translate it back to where it was, otherwise the entire object would move in an arc when rotated.

    One other thing to remember about matrices is that they can be composed (multiplied), but unlike normal multiplication, order matters.

    superchewie on
  • DisrupterDisrupter Registered User regular
    edited February 2011
    Ok, so I think I get everything but projection.

    Let me make sure i have view right:

    The view matrix multiplied by a vector in a 3D world will give you that vectors position within a 2D view?

    Everything else is pretty much what I originally thought. And yeah, I remembered a lot of the basic stuff from my class, like matrix multiplaction, identity matrix, what an inverse matrix was (but not how to determine one...I learned that yesterday thanks to khan :) ).

    I think I may have a decent enough understanding of the math behind the programming concepts now, but I still am a bit lost on some of the concepts (mainly projection matrix).

    Disrupter on
    616610-1.png
  • DisrupterDisrupter Registered User regular
    edited February 2011
    This site helped explain those concepts to me a bit



    http://robertokoci.com/world-view-projection-matrix-unveiled/

    Im still a bit confused as to how the projection matrix works. Like I get what its purpose is now. Does it basically just scale/move the object based on its depth?

    So world matrix takes the object from its own little space and tells you where it would be in the world space? Basically its coordiates and stuff. EX: A vertex may be at -1,-2 on the object space. But if the object is placed at 100,20 in the world that that vertex needs to be at 99,18.

    View matrix takes the object from 3D space and tells you where it would be on a 2D view

    Projection matrix then uses depth of the object to move and scale the object on the 2D plane to take depth into account.

    Is this correct?

    Disrupter on
    616610-1.png
  • superchewiesuperchewie Registered User regular
    edited February 2011
    Yeah, that's pretty much it.

    For the projection matrix, though, remember that it's a type of matrix. It can either be perspective (depth) or orthographic (no depth), or fucked up (god knows what).

    superchewie on
Sign In or Register to comment.