Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (516)
Games in Android Showcase (122)
games submitted by our members
Games in WIP (577)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Inverting Matrices  (Read 910 times)
0 Members and 1 Guest are viewing this topic.
Offline thedanisaur
« Posted 2014-08-22 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 Cool
Offline ClaasJG
« Reply #1 - Posted 2014-08-22 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.
Offline Roquen
« Reply #2 - Posted 2014-08-22 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!
Legends of Yore - The Casual Retro Roguelike
Offline thedanisaur
« Reply #3 - Posted 2014-08-22 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  Tongue

Every village needs an idiot Cool
Offline basil_
« Reply #4 - Posted 2014-08-22 08:46:43 »

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/
Offline Roquen
« Reply #5 - Posted 2014-08-22 08:51:16 »

That's what...not why.  I'm guessing solving IK?
Offline pjt33
« Reply #6 - Posted 2014-08-22 09:22:46 »

JAMA. But you should first ask whether you can avoid matrix inversion, because it can be ill-conditioned.
Offline thedanisaur
« Reply #7 - Posted 2014-08-22 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 dual-quaternion, but my quaternion math is poor and I'm looking to just finish this game and go from there.

Every village needs an idiot Cool
Offline Roquen
« Reply #8 - Posted 2014-08-22 19:18:37 »

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.
Offline Roquen
« Reply #9 - Posted 2014-08-22 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!
Legends of Yore - The Casual Retro Roguelike
Offline Roquen
« Reply #10 - Posted 2014-08-24 06:21:07 »

So did you figure it out?  Either dual-quaternions or LA, zero operations and storage is sufficient.
Offline thedanisaur
« Reply #11 - Posted 2014-08-27 20:05:39 »

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

Every village needs an idiot Cool
Offline Roquen
« Reply #12 - Posted 2014-08-28 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 = MT.  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
  RT(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.
Offline Roquen
« Reply #13 - Posted 2014-08-28 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.
Offline thedanisaur
« Reply #14 - Posted 2014-08-31 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 Cool
Offline Roquen
« Reply #15 - Posted 2014-08-31 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-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.
Pages: [1]
  ignore  |  Print  
 
 

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

TehJavaDev (31 views)
2014-10-27 03:28:38

TehJavaDev (26 views)
2014-10-27 03:27:51

DarkCart (40 views)
2014-10-26 19:37:11

Luminem (21 views)
2014-10-26 10:17:50

Luminem (26 views)
2014-10-26 10:14:04

theagentd (32 views)
2014-10-25 15:46:29

Longarmx (61 views)
2014-10-17 03:59:02

Norakomi (57 views)
2014-10-16 15:22:06

Norakomi (46 views)
2014-10-16 15:20:20

lcass (43 views)
2014-10-15 16:18:58
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!