/// <summary> /// Calculates the inverse matrix. /// </summary> /// <returns>Inverse Matrix3f.</returns> public Matrix3f Inverse() { float det = this.Determinant(); var resultado = new Matrix3f(); if (det == 0) { throw (new ArithmeticException("The matrix is not invertible")); } det = 1 / det; resultado.M11 = det * (this.mM22 * this.mM33 - this.mM23 * this.mM32); resultado.M12 = det * (this.mM13 * this.mM32 - this.mM12 * this.mM33); resultado.M13 = det * (this.mM12 * this.mM23 - this.mM13 * this.mM22); resultado.M21 = det * (this.mM23 * this.mM31 - this.mM21 * this.mM33); resultado.M22 = det * (this.mM11 * this.mM33 - this.mM13 * this.mM31); resultado.M23 = det * (this.mM13 * this.mM21 - this.mM11 * this.mM23); resultado.M31 = det * (this.mM21 * this.mM32 - this.mM22 * this.mM31); resultado.M32 = det * (this.mM12 * this.mM31 - this.mM11 * this.mM32); resultado.M33 = det * (this.mM11 * this.mM22 - this.mM12 * this.mM21); return(resultado); }
/// <summary> /// Calculates the inverse matrix. /// </summary> /// <returns>Inverse Matrix3f.</returns> public Matrix3f Inverse() { float det = this.Determinant(); var resultado = new Matrix3f(); if (det == 0) { throw (new ArithmeticException("The matrix is not invertible")); } det = 1/det; resultado.M11 = det*(this.mM22*this.mM33 - this.mM23*this.mM32); resultado.M12 = det*(this.mM13*this.mM32 - this.mM12*this.mM33); resultado.M13 = det*(this.mM12*this.mM23 - this.mM13*this.mM22); resultado.M21 = det*(this.mM23*this.mM31 - this.mM21*this.mM33); resultado.M22 = det*(this.mM11*this.mM33 - this.mM13*this.mM31); resultado.M23 = det*(this.mM13*this.mM21 - this.mM11*this.mM23); resultado.M31 = det*(this.mM21*this.mM32 - this.mM22*this.mM31); resultado.M32 = det*(this.mM12*this.mM31 - this.mM11*this.mM32); resultado.M33 = det*(this.mM11*this.mM22 - this.mM12*this.mM21); return resultado; }