thedanisaur


«
Posted
20140822 01:20:06 » 

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.

Every village needs an idiot



ClaasJG


«
Reply #1  Posted
20140822 07:09:35 » 

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

My english has to be tweaked. Please show me my mistakes.



Roquen


«
Reply #2  Posted
20140822 07:51:53 » 

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




Games published by our own members! Check 'em out!


thedanisaur


«
Reply #3  Posted
20140822 08:32:55 » 

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

Every village needs an idiot



basil_


«
Reply #4  Posted
20140822 08:46:43 » 





Roquen


«
Reply #5  Posted
20140822 08:51:16 » 

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




pjt33


«
Reply #6  Posted
20140822 09:22:46 » 

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




thedanisaur


«
Reply #7  Posted
20140822 19:07:39 » 

@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 dualquaternion, but my quaternion math is poor and I'm looking to just finish this game and go from there.

Every village needs an idiot



Roquen


«
Reply #8  Posted
20140822 19:18:37 » 

It's the same problem...inverting a kinematic system...except IK is harder with constraints and multiple links. Do dualquaternions...just look it up..smaller and lower complexity.




Roquen


«
Reply #9  Posted
20140822 20:06:24 » 

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




Games published by our own members! Check 'em out!


Roquen


«
Reply #10  Posted
20140824 06:21:07 » 

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




thedanisaur


«
Reply #11  Posted
20140827 20:05:39 » 

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

Every village needs an idiot



Roquen


«
Reply #12  Posted
20140828 08:27:10 » 

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^{1} = M^{T}. That negates the angle or equivalently is the rotation in the opposite direction. If M were a pure translation (no rotation) then M^{1} = 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^{T}(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 qualquaternion representation just replace transpose with conjugation of the rotation part and you're done.




Roquen


«
Reply #13  Posted
20140828 16:14:38 » 

M^{1} = M.
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.




thedanisaur


«
Reply #14  Posted
20140831 08:30:05 » 

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

Every village needs an idiot



Roquen


«
Reply #15  Posted
20140831 10:12:48 » 

The matrix you have M transforms p into p': p' = Mp
To find the equivalent to M^{1} we solve for p.
M^{1}p' = 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.




