I'm working on an OpenGL project in Java, and it has come to point where I'd like to create the transformation matrices in my own code, so i can use them to do world-to-screen point transformations, and vice versa. I've created a Matrix class with support for transformations, and that is all working quite nicely. However, I'm having trouble actually figuring out how to create an inverse transform.
So my question is this:
- Given an arbitrary affine (4x4) transformation matrix, how do you create the inverse transformation matrix? Are some matrices uninvertible? What are the limitations and caveats of inverting a transformation matrix?
From my research, I've heard various methods of doing so, with the simplest being to transpose then negate the matrix. However, this doesn't seem to be actually working. I've heard that this method doesn't work on some matrices, and even that some matrices are uninvertible.
I'm looking for more than just a "plug in this equation" answer, because I'd actually like to understand what's going on when I invert a matrix. This also excludes "just use this library" answers. I might move to a matrix library in the future, but for now I'd like to create it myself.
Edit: Before anyone asks, this is NOT homework. This is a personal project.
Edit: Apparently there's a whole list of strategies for calculating inverse matrices here: http://en.wikipedia.org/wiki/Invertible_matrix