@Override // from IMatrix3 public Matrix3 invertAffine (Matrix3 result) throws SingularMatrixException { float m00 = this.m00, m01 = this.m01; float m10 = this.m10, m11 = this.m11; float m20 = this.m20, m21 = this.m21; // compute the determinant, storing the subdeterminants for later use float det = m00*m11 - m10*m01; if (Math.abs(det) == 0f) { // determinant is zero; matrix is not invertible throw new SingularMatrixException(this.toString()); } float rdet = 1f / det; return result.set(+m11 * rdet, -m10 * rdet, +(m10*m21 - m20*m11) * rdet, -m01 * rdet, +m00 * rdet, -(m00*m21 - m20*m01) * rdet, 0f, 0f, 1f); }
@Override // from IMatrix3 public Matrix3 invertAffine (Matrix3 result) throws SingularMatrixException { float m00 = this.m00, m01 = this.m01; float m10 = this.m10, m11 = this.m11; float m20 = this.m20, m21 = this.m21; // compute the determinant, storing the subdeterminants for later use float det = m00*m11 - m10*m01; if (Math.abs(det) == 0f) { // determinant is zero; matrix is not invertible throw new SingularMatrixException(this.toString()); } float rdet = 1f / det; return result.set(+m11 * rdet, -m10 * rdet, +(m10*m21 - m20*m11) * rdet, -m01 * rdet, +m00 * rdet, -(m00*m21 - m20*m01) * rdet, 0f, 0f, 1f); }
/** * {@inheritDoc} This code is based on the examples in the * <a href="http://www.j3d.org/matrix_faq/matrfaq_latest.html">Matrix and Quaternion FAQ</a>. */ @Override // from IMatrix3 public Matrix3 invert (Matrix3 result) throws SingularMatrixException { float m00 = this.m00, m01 = this.m01, m02 = this.m02; float m10 = this.m10, m11 = this.m11, m12 = this.m12; float m20 = this.m20, m21 = this.m21, m22 = this.m22; // compute the determinant, storing the subdeterminants for later use float sd00 = m11*m22 - m21*m12; float sd10 = m01*m22 - m21*m02; float sd20 = m01*m12 - m11*m02; float det = m00*sd00 + m20*sd20 - m10*sd10; if (Math.abs(det) == 0f) { // determinant is zero; matrix is not invertible throw new SingularMatrixException(this.toString()); } float rdet = 1f / det; return result.set(+sd00 * rdet, -(m10*m22 - m20*m12) * rdet, +(m10*m21 - m20*m11) * rdet, -sd10 * rdet, +(m00*m22 - m20*m02) * rdet, -(m00*m21 - m20*m01) * rdet, +sd20 * rdet, -(m00*m12 - m10*m02) * rdet, +(m00*m11 - m10*m01) * rdet); }
/** * {@inheritDoc} This code is based on the examples in the * <a href="http://www.j3d.org/matrix_faq/matrfaq_latest.html">Matrix and Quaternion FAQ</a>. */ @Override // from IMatrix3 public Matrix3 invert (Matrix3 result) throws SingularMatrixException { float m00 = this.m00, m01 = this.m01, m02 = this.m02; float m10 = this.m10, m11 = this.m11, m12 = this.m12; float m20 = this.m20, m21 = this.m21, m22 = this.m22; // compute the determinant, storing the subdeterminants for later use float sd00 = m11*m22 - m21*m12; float sd10 = m01*m22 - m21*m02; float sd20 = m01*m12 - m11*m02; float det = m00*sd00 + m20*sd20 - m10*sd10; if (Math.abs(det) == 0f) { // determinant is zero; matrix is not invertible throw new SingularMatrixException(this.toString()); } float rdet = 1f / det; return result.set(+sd00 * rdet, -(m10*m22 - m20*m12) * rdet, +(m10*m21 - m20*m11) * rdet, -sd10 * rdet, +(m00*m22 - m20*m02) * rdet, -(m00*m21 - m20*m01) * rdet, +sd20 * rdet, -(m00*m12 - m10*m02) * rdet, +(m00*m11 - m10*m01) * rdet); }
if (Math.abs(det) == 0f) { throw new SingularMatrixException(this.toString());
if (Math.abs(det) == 0f) { throw new SingularMatrixException(this.toString());