Here you can find the source of invertSymmetric3x3(final double[][] m, final double[][] inverse)
Parameter | Description |
---|---|
m | symmetric matrix to invert. |
inverse | inverse of m is stored here. |
public static void invertSymmetric3x3(final double[][] m, final double[][] inverse)
//package com.java2s; public class Main { /**/* w w w.j a v a 2 s . c o m*/ * Inverts a (invertible) symmetric 3x3 matrix. * * @param m * symmetric matrix to invert. * @param inverse * inverse of {@code m} is stored here. */ public static void invertSymmetric3x3(final double[][] m, final double[][] inverse) { final double a00 = m[2][2] * m[1][1] - m[1][2] * m[1][2]; final double a01 = m[0][2] * m[1][2] - m[2][2] * m[0][1]; final double a02 = m[0][1] * m[1][2] - m[0][2] * m[1][1]; final double a11 = m[2][2] * m[0][0] - m[0][2] * m[0][2]; final double a12 = m[0][1] * m[0][2] - m[0][0] * m[1][2]; final double a22 = m[0][0] * m[1][1] - m[0][1] * m[0][1]; final double Dinv = 1.0 / ((m[0][0] * a00) + (m[1][0] * a01) + (m[0][2] * a02)); inverse[0][0] = a00 * Dinv; inverse[1][0] = inverse[0][1] = a01 * Dinv; inverse[2][0] = inverse[0][2] = a02 * Dinv; inverse[1][1] = a11 * Dinv; inverse[2][1] = inverse[1][2] = a12 * Dinv; inverse[2][2] = a22 * Dinv; } }