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

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -