Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (603)
Games in Android Showcase (171)
games submitted by our members
Games in WIP (651)
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 1381 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

Senior Devvie

Medals: 19

« 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 for inspiration.


My english has to be tweaked. Please show me my mistakes.
Online 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_

« JGO Bitwise Duke »

Medals: 195
Exp: 12 years

« Reply #4 - Posted 2014-08-22 08:46:43 »

i use

all toxic-tools are very good.
Online Roquen
« Reply #5 - Posted 2014-08-22 08:51:16 »

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

« JGO Spiffy Duke »

Medals: 40
Projects: 4
Exp: 7 years

« 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
Online 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.
Online 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
Online 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
Online 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.
Online 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
Online 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  
You cannot reply to this message, because it is very, very old.

SHC (11 views)
2015-08-01 03:58:20

Jesse (16 views)
2015-07-29 04:35:27

Riven (38 views)
2015-07-27 16:38:00

Riven (19 views)
2015-07-27 15:35:20

Riven (22 views)
2015-07-27 12:26:13

Riven (12 views)
2015-07-27 12:23:39

BurntPizza (32 views)
2015-07-25 00:14:37

BurntPizza (43 views)
2015-07-24 22:06:39

BurntPizza (25 views)
2015-07-24 06:06:53

NoxInc (31 views)
2015-07-22 22:16:53
List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21 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‑
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!