コード例 #1
0
        /// <summary>
        /// Inverts this matrix.
        /// </summary>
        /// <exception cref="Vertesaur.NoInverseException">An inverse requires a valid non-zero finite determinant.</exception>
        public void Invert()
        {
            var result = new Matrix4();

            Contract.Assume(result.IsIdentity);
            if (SquareMatrixOperations.GaussJordanEliminationDestructive(Clone(), result))
            {
                CopyFrom(result);
            }
            else
            {
                throw new NoInverseException();
            }
        }
コード例 #2
0
        /// <summary>
        /// Generates a matrix which is the inverse.
        /// </summary>
        /// <returns>The inverse of the matrix.</returns>
        /// <exception cref="Vertesaur.NoInverseException">An inverse requires a valid non-zero finite determinant.</exception>
        public Matrix4 GetInverse()
        {
            Contract.Ensures(Contract.Result <Matrix4>() != null);
            var result = new Matrix4();

            Contract.Assume(result.IsIdentity);
            if (SquareMatrixOperations.GaussJordanEliminationDestructive(Clone(), result))
            {
                return(result);
            }
            else
            {
                throw new NoInverseException();
            }
        }
コード例 #3
0
 /// <summary>
 /// Calculates the determinant of the matrix.
 /// </summary>
 /// <returns>The determinant.</returns>
 public double CalculateDeterminant()
 {
     return(SquareMatrixOperations.CalculateDeterminantDestructive(Clone()));
 }