Here you can find the source of matrixDeterminant(final float[] m, final int m_offset)
Parameter | Description |
---|---|
m | 4x4 matrix in column-major order, the source |
m_offset | offset in given array <i>m</i>, i.e. start of the 4x4 matrix |
public static float matrixDeterminant(final float[] m, final int m_offset)
//package com.java2s; public class Main { /**// w w w . java 2 s .c o m * Returns the determinant of the given matrix * * @param m 4x4 matrix in column-major order, the source * @param m_offset offset in given array <i>m</i>, i.e. start of the 4x4 * matrix * @return the matrix determinant */ public static float matrixDeterminant(final float[] m, final int m_offset) { float a11 = m[1 + 4 * 1 + m_offset]; float a21 = m[2 + 4 * 1 + m_offset]; float a31 = m[3 + 4 * 1 + m_offset]; float a12 = m[1 + 4 * 2 + m_offset]; float a22 = m[2 + 4 * 2 + m_offset]; float a32 = m[3 + 4 * 2 + m_offset]; float a13 = m[1 + 4 * 3 + m_offset]; float a23 = m[2 + 4 * 3 + m_offset]; float a33 = m[3 + 4 * 3 + m_offset]; float ret = 0; ret += m[0 + m_offset] * (+a11 * (a22 * a33 - a23 * a32) - a12 * (a21 * a33 - a23 * a31) + a13 * (a21 * a32 - a22 * a31)); a11 = m[1 + 4 * 0 + m_offset]; a21 = m[2 + 4 * 0 + m_offset]; a31 = m[3 + 4 * 0 + m_offset]; ret -= m[0 + 4 * 1 + m_offset] * (+a11 * (a22 * a33 - a23 * a32) - a12 * (a21 * a33 - a23 * a31) + a13 * (a21 * a32 - a22 * a31)); a12 = m[1 + 4 * 1 + m_offset]; a22 = m[2 + 4 * 1 + m_offset]; a32 = m[3 + 4 * 1 + m_offset]; ret += m[0 + 4 * 2 + m_offset] * (+a11 * (a22 * a33 - a23 * a32) - a12 * (a21 * a33 - a23 * a31) + a13 * (a21 * a32 - a22 * a31)); a13 = m[1 + 4 * 2 + m_offset]; a23 = m[2 + 4 * 2 + m_offset]; a33 = m[3 + 4 * 2 + m_offset]; ret -= m[0 + 4 * 3 + m_offset] * (+a11 * (a22 * a33 - a23 * a32) - a12 * (a21 * a33 - a23 * a31) + a13 * (a21 * a32 - a22 * a31)); return ret; } /** * Returns the determinant of the given matrix * * @param m 4x4 matrix in column-major order, the source * @return the matrix determinant */ public static float matrixDeterminant(final float[] m) { float a11 = m[1 + 4 * 1]; float a21 = m[2 + 4 * 1]; float a31 = m[3 + 4 * 1]; float a12 = m[1 + 4 * 2]; float a22 = m[2 + 4 * 2]; float a32 = m[3 + 4 * 2]; float a13 = m[1 + 4 * 3]; float a23 = m[2 + 4 * 3]; float a33 = m[3 + 4 * 3]; float ret = 0; ret += m[0] * (+a11 * (a22 * a33 - a23 * a32) - a12 * (a21 * a33 - a23 * a31) + a13 * (a21 * a32 - a22 * a31)); a11 = m[1 + 4 * 0]; a21 = m[2 + 4 * 0]; a31 = m[3 + 4 * 0]; ret -= m[0 + 4 * 1] * (+a11 * (a22 * a33 - a23 * a32) - a12 * (a21 * a33 - a23 * a31) + a13 * (a21 * a32 - a22 * a31)); a12 = m[1 + 4 * 1]; a22 = m[2 + 4 * 1]; a32 = m[3 + 4 * 1]; ret += m[0 + 4 * 2] * (+a11 * (a22 * a33 - a23 * a32) - a12 * (a21 * a33 - a23 * a31) + a13 * (a21 * a32 - a22 * a31)); a13 = m[1 + 4 * 2]; a23 = m[2 + 4 * 2]; a33 = m[3 + 4 * 2]; ret -= m[0 + 4 * 3] * (+a11 * (a22 * a33 - a23 * a32) - a12 * (a21 * a33 - a23 * a31) + a13 * (a21 * a32 - a22 * a31)); return ret; } }