+ Reply to Thread
Results 1 to 5 of 5

Thread: Matrix math and isometric 2d..

  1. #1
    Senior Member
    Join Date
    Oct 2005
    Location
    Montreal, Quebec
    Posts
    797

    Default Matrix math and isometric 2d..

    Ok first off - if you're going to reply "use 3d", then please don't.

    Alright, I'm doing silly stuff - I'm trying to have a "3d" space simulation underneath the hood of my 2d isometric engine. This is so I can do stuff like bullet trajectory simulation, 3d picking, etc..

    Now, I've got it working pretty decently in some ways, but I've hit the wall on something stupid. I've got an Isometric projection matrix, like this:

    Code:
    ISO Projection			
    0.70710    0.35350     0.00000    0.00000
    0.00000   -0.86600     0.00000    0.00000
    -0.70710   0.35350     0.00000    0.00000
    0.00000    0.00000     0.00000    1.00000
    That's dimetric projection actually, but you get it.

    Now, that works just fine. I can render cubes around my ingame 2d objects in the proper world space. However, now I need to be able to unproject so that I can ray pick (target) with the cursor. I can get the coords in the traditional 2d way, but that won't respect collision hulls in the world sim and will give me incorrect results.

    So, I get a transposed projection matrix (since I can't seem to invert it, and anyway it's just a rotation matrix so it should work fine transposed):

    Code:
    Transposed ISO Projection			
    0.70710    0.00000   -0.70710    0.00000
    0.35350   -0.86600    0.35350    0.00000
    0.00000    0.00000    0.00000    0.00000
    0.00000    0.00000    0.00000    1.00000
    But, it doesn't. I get mangled numbers out of that.. If I project the screen coords of 500,0,500 and then unproject them I don't get the original.

    Anyone got a better handle on the math here? I can't quite figure out what I'm doing wrong.
    "Don't lose your loose change."
    Jason Maskell, Tamed Tornado Software

  2. #2
    Senior Member
    Join Date
    Jul 2004
    Location
    San Diego, CA
    Posts
    1,148

    Default

    No time at the moment to figure out what you really need to do, but you can't simply transpose a projection matrix to get the inverse. Transpose only works with a pure rotation matrix (with row/column vectors that are unit and perpendicular to each other).
    Twitchy Thumbs Entertainment, Inc.
    http://www.twitchythumbs.com

  3. #3
    Senior Member
    Join Date
    Oct 2005
    Location
    Montreal, Quebec
    Posts
    797

    Default

    Quote Originally Posted by Jim Buck View Post
    No time at the moment to figure out what you really need to do, but you can't simply transpose a projection matrix to get the inverse. Transpose only works with a pure rotation matrix (with row/column vectors that are unit and perpendicular to each other).
    Yep, but that's what it is. It's not a real projection matrix, it literally is just the two rotates.

    I'm still trying to narrow down what exactly the problem is. My matrix math is rusty as hell after a good 6 months of complete disuse.
    "Don't lose your loose change."
    Jason Maskell, Tamed Tornado Software

  4. #4
    Senior Member
    Join Date
    Sep 2004
    Location
    San Jose, CA.
    Posts
    1,726

    Default

    Shouldn't element (2, 2) be 1.0? It's zero above, which is going to scale z and wipe out data that you probably want. If you do intend it to be zero, then this matrix is not the transposable rotation matrix that you think it is
    Peter Young | www.attitudegain.com | Linkedin | Twitter

    Projects:
    Meridian 59: Evolution
    ???
    ???

  5. #5
    Senior Member
    Join Date
    Oct 2005
    Location
    Montreal, Quebec
    Posts
    797

    Default

    Quote Originally Posted by vjvj View Post
    Shouldn't element (2, 2) be 1.0? It's zero above, which is going to scale z and wipe out data that you probably want. If you do intend it to be zero, then this matrix is not the transposable rotation matrix that you think it is
    You were right there! My matrix math really sucks.

    The solution turned out to be that the matrix was indeed, not transposable. It was also not easily invertible.

    I finally found a web page after much MUCH googling that describes an inversion algorithm that works for this matrix, and gives me the result I expect. The "Moore-Penrose pseudoinverse" didn't work, but this one does. (To be precise, the MP algo did invert it, but it didn't appear to be correct afterwards.)

    I really need to get better at this stuff - but every time I start to get good at it I stop needing it and forget everything.
    "Don't lose your loose change."
    Jason Maskell, Tamed Tornado Software

+ Reply to Thread

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts