Inverting Matrices

This question is related to openGL, however it’s fairly general so I thought I’d put it here.

Anyone, know any good libraries that I could use to perform matrix operations? I really just need to be able to invert the matrix.

If you just need such simple operations
I would roll out my own implementation.
See as example http://goo.gl/zBD3Kl for inspiration.

ClaasJG

Information is good. Why do you think you need to invert? What kind of matrix to you think you need to invert?

3D skeletal animation, I’ll just roll out my own solution I guess. I know the math I just don’t want to write it :stuck_out_tongue:

i use https://code.google.com/p/toxiclibs/source/browse/trunk/toxiclibs/src.core/toxi/geom/Matrix4x4.java?r=316

all toxic-tools are very good. http://toxiclibs.org/

That’s what…not why. I’m guessing solving IK?

JAMA. But you should first ask whether you can avoid matrix inversion, because it can be ill-conditioned.

@Roquen: Nope linear blend skinning. Sorry, but I’m not going to go into the math behind it, because if I write out the actual “why” then I’ve just done precisely what I don’t want to do, plus more. If you know of a way to avoid inversion for skinning please do share.

@everyone: Also, this is not a big deal for performance, because you only need these matrices once(I can store them into my file and just read them in). Now I know I could do dual-quaternion, but my quaternion math is poor and I’m looking to just finish this game and go from there.

It’s the same problem…inverting a kinematic system…except IK is harder with constraints and multiple links. Do dual-quaternions…just look it up…smaller and lower complexity.

Oh and if you’re set on LA, then add SE(3) to your web search.

So did you figure it out? Either dual-quaternions or LA, zero operations and storage is sufficient.

Nope, been busy. I might take a crack at this soon, considering the game I’m working on requires it :wink:

OK rather than drag this out, here’s the zero additional computation & storage solution.

If you have a matrix M which represents a rotation + translation then:

p' = Mp (to choose a convention).

We want M-1. But M isn’t an arbitrary matrix. If M were a pure rotation (no translation) then M<sup>-1</sup> = M<sup>T</sup>. That negates the angle or equivalently is the rotation in the opposite direction. If M were a pure translation (no rotation) then M<sup>-1</sup> = -M. If you know these things and can’t see how to invert M in general, then you’re getting lost in computation. Let’s call the rotation part (upper 3x3) R and the translation part t . Then we can rewrite the equation:

P' = Rp + t

solve for p:
p' - t = Rp R<sup>T</sup>(p' - t) = p
So you can just write a specialize routine that just computes the inverse directly from the information of M without actually ever computing M-1. The same holds for a qual-quaternion representation just replace transpose with conjugation of the rotation part and you’re done.

To prevent confusion…this is actually wrong. M and -M if it’s a translation represent the same since 4x4 is homogeneous. The diagonal values remain ‘1’ and just the translation values are negated.

I’m confused, if I already know p then why am I not just solving for p’?

The matrix you have M transforms p into p’: p’ = Mp

To find the equivalent to M-1 we solve for p.

M-1p’ = p

but since M is a special case can we rework the original equation to prevent ever needed to compute it. Even knowing it’s a special case requires computation if we actually wanted to store the inverse for some reason.