math - Inverting a 4x4 Matrix algorithm -


i'm trying invert 4x4 matrices, i've seen examples of calculating determinant few dozens of calculations, did not seem work me, might've messed somewhere, i've been trying find way solve this, answer this:

public matrix inverse() {     double[] array = new double[]{         1/m[0], m[4],   m[8],       0,         m[1],   1/m[5], m[9],       0,         m[2],   m[6],   1/m[10],    0,         -m[12], -m[13], -m[14],     1/m[15]     };     return new matrix(array); } 

basicly is, calculating invert of it's components, has been working quite well, expect number 15, last number, it's been spewing out infinity reason, have clue why? guess division zero, question, inverse of 0? answer 0?

(not sure if relevant, matrices row-major)

your attempt write down inverse of 4x4 matrix utterly wrong. there's absolutely no point trying fix since can never work.

you ask result of 1/0 is. well, division 0 , result not defined. there no real number x satisfies 1/0 == x. if there 1 == x*0 == 0, contradiction. on computer, attempting perform division 0 leads error, or results in special floating point value inf being returned. latter appears happens in environment.

i don't know why rejected determinant based code. perhaps found tricky implement. that's how is. aren't going shortcut complexity.


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -