Пример #1
0
 /// <summary>
 /// Returns the specified submatrix of the given matrix.
 /// </summary>
 /// <param name="matrix">The matrix whose submatrix is to returned.</param>
 /// <param name="row">The row to be removed.</param>
 /// <param name="column">The column to be removed.</param>
 public static float Submatrix(Matrix2x2f matrix, int row, int column)
 {
     if (row < 0 || row > 1)
     {
         throw new ArgumentOutOfRangeException("row", "Rows for Matrix2x2f run from 0 to 1, inclusive.");
     }
     if (column < 0 || column > 1)
     {
         throw new ArgumentOutOfRangeException("column", "Columns for Matrix2x2f run from 0 to 1, inclusive.");
     }
     if (row == 0 && column == 0)
     {
         return(matrix.M22);
     }
     else if (row == 0 && column == 1)
     {
         return(matrix.M21);
     }
     else if (row == 1 && column == 0)
     {
         return(matrix.M12);
     }
     else
     {
         return(matrix.M11);
     }
 }
Пример #2
0
 /// <summary>
 /// Returns a matrix where each element is the fractional part of the specified element.
 /// </summary>
 /// <param name="value">A matrix.</param>
 /// <returns>The fractional of value.</returns>
 public static Matrix2x2f Fractional(Matrix2x2f value)
 {
     return(new Matrix2x2f(Functions.Fractional(value.M11), Functions.Fractional(value.M21), Functions.Fractional(value.M12), Functions.Fractional(value.M22)));
 }
Пример #3
0
 /// <summary>
 /// Returns a matrix where each element is the integral part of the specified element.
 /// </summary>
 /// <param name="value">A matrix.</param>
 /// <returns>The integral of value.</returns>
 public static Matrix2x2f Truncate(Matrix2x2f value)
 {
     return(new Matrix2x2f(Functions.Truncate(value.M11), Functions.Truncate(value.M21), Functions.Truncate(value.M12), Functions.Truncate(value.M22)));
 }
Пример #4
0
 public static Matrix2x2f Add(Matrix2x2f left, Matrix2x2f right)
 {
     return(new Matrix2x2f(left.M11 + right.M11, left.M21 + right.M21, left.M12 + right.M12, left.M22 + right.M22));
 }
Пример #5
0
 /// <summary>
 /// Calculates the transpose of the specified matrix.
 /// </summary>
 /// <param name="matrix">The matrix whose transpose is to be calculated.</param>
 /// <returns>The transpose of the specified matrix.</returns>
 public static Matrix2x2f Transpose(Matrix2x2f matrix)
 {
     return(new Matrix2x2f(matrix.M11, matrix.M12, matrix.M21, matrix.M22));
 }
Пример #6
0
        /// <summary>
        /// Calculates the inverse of the specified matrix.
        /// </summary>
        /// <param name="matrix">The matrix whose inverse is to be calculated.</param>
        /// <param name="determinant">When the method completes, contains the determinant of the matrix.</param>
        public static Matrix2x2f Invert(Matrix2x2f matrix)
        {
            float determinant;

            return(Invert(matrix, out determinant));
        }
Пример #7
0
 /// <summary>
 /// Returns a matrix where each element is rounded to the nearest integral value.
 /// </summary>
 /// <param name="value">A matrix.</param>
 /// <param name="digits">The number of fractional digits in the return value.</param>
 /// <param name="mode">Specification for how to round value if it is midway between two other numbers.</param>
 /// <returns>The result of rounding value.</returns>
 public static Matrix2x2f Round(Matrix2x2f value, int digits, MidpointRounding mode)
 {
     return(new Matrix2x2f(Functions.Round(value.M11, digits, mode), Functions.Round(value.M21, digits, mode), Functions.Round(value.M12, digits, mode), Functions.Round(value.M22, digits, mode)));
 }
Пример #8
0
 /// <summary>
 /// Determines whether any element of a matrix is non-zero.
 /// </summary>
 /// <param name="value">A vector.</param>
 /// <returns>true if any elements are non-zero; false otherwise.</returns>
 public static bool Any(Matrix2x2f value)
 {
     return(value.M11 != 0 || value.M21 != 0 || value.M12 != 0 || value.M22 != 0);
 }
Пример #9
0
 /// <summary>
 /// Determines whether any elements of a matrix satisfy a condition.
 /// </summary>
 /// <param name="value">A vector.</param>
 /// <param name="predicate">A function to test each element for a condition.</param>
 /// <returns>true if any element of the matrix passes the test in the specified
 /// predicate; otherwise, false.</returns>
 public static bool Any(Matrix2x2f value, Predicate <float> predicate)
 {
     return(predicate(value.M11) || predicate(value.M21) || predicate(value.M12) || predicate(value.M22));
 }
Пример #10
0
 public static Matrix2x2f Divide(Matrix2x2f matrix, float scalar)
 {
     return(new Matrix2x2f(matrix.M11 / scalar, matrix.M21 / scalar, matrix.M12 / scalar, matrix.M22 / scalar));
 }
Пример #11
0
 /// <summary>
 /// Determines whether all elements of a matrix are non-zero.
 /// </summary>
 /// <param name="value">A matrix.</param>
 /// <returns>true if all elements are non-zero; false otherwise.</returns>
 public static bool All(Matrix2x2f value)
 {
     return(value.M11 != 0 && value.M21 != 0 && value.M12 != 0 && value.M22 != 0);
 }
Пример #12
0
 public static Matrix2x2f Multiply(Matrix2x2f matrix, float scalar)
 {
     return(new Matrix2x2f(matrix.M11 * scalar, matrix.M21 * scalar, matrix.M12 * scalar, matrix.M22 * scalar));
 }
Пример #13
0
 public static Matrix2x4f Multiply(Matrix2x2f left, Matrix2x4f right)
 {
     return(new Matrix2x4f(left.M11 * right.M11 + left.M12 * right.M21, left.M21 * right.M11 + left.M22 * right.M21, left.M11 * right.M12 + left.M12 * right.M22, left.M21 * right.M12 + left.M22 * right.M22, left.M11 * right.M13 + left.M12 * right.M23, left.M21 * right.M13 + left.M22 * right.M23, left.M11 * right.M14 + left.M12 * right.M24, left.M21 * right.M14 + left.M22 * right.M24));
 }
Пример #14
0
 public static Matrix2x2f Subtract(Matrix2x2f left, Matrix2x2f right)
 {
     return(new Matrix2x2f(left.M11 - right.M11, left.M21 - right.M21, left.M12 - right.M12, left.M22 - right.M22));
 }
Пример #15
0
 /// <summary>
 /// Returns a matrix where each element is rounded to the nearest integral value.
 /// </summary>
 /// <param name="value">A matrix.</param>
 /// <returns>The result of rounding value.</returns>
 public static Matrix2x2f Round(Matrix2x2f value)
 {
     return(new Matrix2x2f(Functions.Round(value.M11), Functions.Round(value.M21), Functions.Round(value.M12), Functions.Round(value.M22)));
 }
Пример #16
0
 /// <summary>
 /// Maps the elements of a matrix and returns the result.
 /// </summary>
 /// <param name="value">The matrix to map.</param>
 /// <param name="mapping">A mapping function to apply to each element.</param>
 /// <returns>The result of mapping each element of value.</returns>
 public static Matrix2x2f Map(Matrix2x2f value, Func <float, float> mapping)
 {
     return(new Matrix2x2f(mapping(value.M11), mapping(value.M21), mapping(value.M12), mapping(value.M22)));
 }
Пример #17
0
 /// <summary>
 /// Returns a matrix where each element is rounded to the nearest integral value.
 /// </summary>
 /// <param name="value">A matrix.</param>
 /// <param name="digits">The number of fractional digits in the return value.</param>
 /// <returns>The result of rounding value.</returns>
 public static Matrix2x2f Round(Matrix2x2f value, int digits)
 {
     return(new Matrix2x2f(Functions.Round(value.M11, digits), Functions.Round(value.M21, digits), Functions.Round(value.M12, digits), Functions.Round(value.M22, digits)));
 }
Пример #18
0
 /// <summary>
 /// Multiplys the elements of two matrices and returns the result.
 /// </summary>
 /// <param name="left">The first matrix to modulate.</param>
 /// <param name="right">The second matrix to modulate.</param>
 /// <returns>The result of multiplying each element of left by the matching element in right.</returns>
 public static Matrix2x2f Modulate(Matrix2x2f left, Matrix2x2f right)
 {
     return(new Matrix2x2f(left.M11 * right.M11, left.M21 * right.M21, left.M12 * right.M12, left.M22 * right.M22));
 }
Пример #19
0
 /// <summary>
 /// Calculates the reciprocal of each element in the matrix.
 /// </summary>
 /// <param name="value">A matrix.</param>
 /// <returns>A matrix with the reciprocal of each of values elements.</returns>
 public static Matrix2x2f Reciprocal(Matrix2x2f value)
 {
     return(new Matrix2x2f(1 / value.M11, 1 / value.M21, 1 / value.M12, 1 / value.M22));
 }
Пример #20
0
 /// <summary>
 /// Returns a matrix that contains the highest value from each pair of elements.
 /// </summary>
 /// <param name="value1">The first matrix.</param>
 /// <param name="value2">The second matrix.</param>
 /// <returns>The highest of each element in left and the matching element in right.</returns>
 public static Matrix2x2f Max(Matrix2x2f value1, Matrix2x2f value2)
 {
     return(new Matrix2x2f(Functions.Max(value1.M11, value2.M11), Functions.Max(value1.M21, value2.M21), Functions.Max(value1.M12, value2.M12), Functions.Max(value1.M22, value2.M22)));
 }
Пример #21
0
 /// <summary>
 /// Calculates the inverse of the specified matrix.
 /// </summary>
 /// <param name="matrix">The matrix whose inverse is to be calculated.</param>
 /// <param name="determinant">When the method completes, contains the determinant of the matrix.</param>
 public static Matrix2x2f Invert(Matrix2x2f matrix, out float determinant)
 {
     determinant = matrix.M11 * matrix.M22 - matrix.M12 * matrix.M21;
     return(new Matrix2x2f(determinant * matrix.M22, determinant * -matrix.M12, determinant * -matrix.M21, determinant * matrix.M11));
 }
Пример #22
0
 /// <summary>
 /// Constrains each element to a given range.
 /// </summary>
 /// <param name="value">A matrix to constrain.</param>
 /// <param name="min">The minimum values for each element.</param>
 /// <param name="max">The maximum values for each element.</param>
 /// <returns>A matrix with each element constrained to the given range.</returns>
 public static Matrix2x2f Clamp(Matrix2x2f value, Matrix2x2f min, Matrix2x2f max)
 {
     return(new Matrix2x2f(Functions.Clamp(value.M11, min.M11, max.M11), Functions.Clamp(value.M21, min.M21, max.M21), Functions.Clamp(value.M12, min.M12, max.M12), Functions.Clamp(value.M22, min.M22, max.M22)));
 }
Пример #23
0
 /// <summary>
 /// Calculates the determinant of the matrix.
 /// </summary>
 /// <returns>The determinant of the matrix.</returns>
 public static float Determinant(Matrix2x2f matrix)
 {
     return(matrix.M11 * matrix.M22 - matrix.M12 * matrix.M21);
 }
Пример #24
0
 /// <summary>
 /// Returns a matrix where each element is the smallest integral value that
 /// is greater than or equal to the specified element.
 /// </summary>
 /// <param name="value">A matrix.</param>
 /// <returns>The ceiling of value.</returns>
 public static Matrix2x2f Ceiling(Matrix2x2f value)
 {
     return(new Matrix2x2f(Functions.Ceiling(value.M11), Functions.Ceiling(value.M21), Functions.Ceiling(value.M12), Functions.Ceiling(value.M22)));
 }
Пример #25
0
 public static Matrix4x2f Multiply(Matrix4x2f left, Matrix2x2f right)
 {
     return(new Matrix4x2f(left.M11 * right.M11 + left.M12 * right.M21, left.M21 * right.M11 + left.M22 * right.M21, left.M31 * right.M11 + left.M32 * right.M21, left.M41 * right.M11 + left.M42 * right.M21, left.M11 * right.M12 + left.M12 * right.M22, left.M21 * right.M12 + left.M22 * right.M22, left.M31 * right.M12 + left.M32 * right.M22, left.M41 * right.M12 + left.M42 * right.M22));
 }
Пример #26
0
 public static Matrix2x2f Negate(Matrix2x2f value)
 {
     return(new Matrix2x2f(-value.M11, -value.M21, -value.M12, -value.M22));
 }