Java Matrix Invert invert3x3(float[] mat)

Here you can find the source of invert3x3(float[] mat)

Description

invertx

License

Open Source License

Declaration

public static void invert3x3(float[] mat) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static void invert3x3(float[] mat) {
        double sub00 = mat[5] * mat[10] - mat[6] * mat[9];
        double sub01 = mat[4] * mat[10] - mat[6] * mat[8];
        double sub02 = mat[4] * mat[9] - mat[5] * mat[8];
        double sub10 = mat[1] * mat[10] - mat[2] * mat[9];
        double sub11 = mat[0] * mat[10] - mat[2] * mat[8];
        double sub12 = mat[0] * mat[9] - mat[1] * mat[8];
        double sub20 = mat[1] * mat[6] - mat[2] * mat[5];
        double sub21 = mat[0] * mat[6] - mat[2] * mat[4];
        double sub22 = mat[0] * mat[5] - mat[1] * mat[4];
        double det = mat[0] * sub00 - mat[1] * sub01 + mat[2] * sub02;

        mat[0] = (float) (sub00 / det);
        mat[1] = -(float) (sub10 / det);
        mat[2] = (float) (sub20 / det);
        mat[4] = -(float) (sub01 / det);
        mat[5] = (float) (sub11 / det);
        mat[6] = -(float) (sub21 / det);
        mat[8] = (float) (sub02 / det);
        mat[9] = -(float) (sub12 / det);
        mat[10] = (float) (sub22 / det);
    }//from   w w w.  j  ava 2s.c o m
}

Related

  1. invert(double a[][])
  2. invert(final int[][] input)
  3. invert(float[] mat)
  4. invert2x2(final double[][] src, final double[][] dest)
  5. invert44Matrix(final double[] m, final double[] invOut)
  6. invertDataSet(double[][] dataSet)
  7. invertMatrix(int[][] matrix)
  8. invertMatrix3x3(float[] result, float[] m)