Beispiel #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 Matrix3x2f Submatrix(Matrix4x3f matrix, int row, int column)
 {
     if (row < 0 || row > 3)
     {
         throw new ArgumentOutOfRangeException("row", "Rows for Matrix4x3f run from 0 to 3, inclusive.");
     }
     if (column < 0 || column > 2)
     {
         throw new ArgumentOutOfRangeException("column", "Columns for Matrix4x3f run from 0 to 2, inclusive.");
     }
     if (row == 0 && column == 0)
     {
         return(new Matrix3x2f(matrix.M22, matrix.M32, matrix.M42, matrix.M23, matrix.M33, matrix.M43));
     }
     else if (row == 0 && column == 1)
     {
         return(new Matrix3x2f(matrix.M21, matrix.M31, matrix.M41, matrix.M23, matrix.M33, matrix.M43));
     }
     else if (row == 0 && column == 2)
     {
         return(new Matrix3x2f(matrix.M21, matrix.M31, matrix.M41, matrix.M22, matrix.M32, matrix.M42));
     }
     else if (row == 1 && column == 0)
     {
         return(new Matrix3x2f(matrix.M12, matrix.M32, matrix.M42, matrix.M13, matrix.M33, matrix.M43));
     }
     else if (row == 1 && column == 1)
     {
         return(new Matrix3x2f(matrix.M11, matrix.M31, matrix.M41, matrix.M13, matrix.M33, matrix.M43));
     }
     else if (row == 1 && column == 2)
     {
         return(new Matrix3x2f(matrix.M11, matrix.M31, matrix.M41, matrix.M12, matrix.M32, matrix.M42));
     }
     else if (row == 2 && column == 0)
     {
         return(new Matrix3x2f(matrix.M12, matrix.M22, matrix.M42, matrix.M13, matrix.M23, matrix.M43));
     }
     else if (row == 2 && column == 1)
     {
         return(new Matrix3x2f(matrix.M11, matrix.M21, matrix.M41, matrix.M13, matrix.M23, matrix.M43));
     }
     else if (row == 2 && column == 2)
     {
         return(new Matrix3x2f(matrix.M11, matrix.M21, matrix.M41, matrix.M12, matrix.M22, matrix.M42));
     }
     else if (row == 3 && column == 0)
     {
         return(new Matrix3x2f(matrix.M12, matrix.M22, matrix.M32, matrix.M13, matrix.M23, matrix.M33));
     }
     else if (row == 3 && column == 1)
     {
         return(new Matrix3x2f(matrix.M11, matrix.M21, matrix.M31, matrix.M13, matrix.M23, matrix.M33));
     }
     else
     {
         return(new Matrix3x2f(matrix.M11, matrix.M21, matrix.M31, matrix.M12, matrix.M22, matrix.M32));
     }
 }
Beispiel #2
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 Matrix4x3f Round(Matrix4x3f value)
 {
     return(new Matrix4x3f(Functions.Round(value.M11), Functions.Round(value.M21), Functions.Round(value.M31), Functions.Round(value.M41), Functions.Round(value.M12), Functions.Round(value.M22), Functions.Round(value.M32), Functions.Round(value.M42), Functions.Round(value.M13), Functions.Round(value.M23), Functions.Round(value.M33), Functions.Round(value.M43)));
 }
Beispiel #3
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 Matrix4x3f Clamp(Matrix4x3f value, Matrix4x3f min, Matrix4x3f max)
 {
     return(new Matrix4x3f(Functions.Clamp(value.M11, min.M11, max.M11), Functions.Clamp(value.M21, min.M21, max.M21), Functions.Clamp(value.M31, min.M31, max.M31), Functions.Clamp(value.M41, min.M41, max.M41), Functions.Clamp(value.M12, min.M12, max.M12), Functions.Clamp(value.M22, min.M22, max.M22), Functions.Clamp(value.M32, min.M32, max.M32), Functions.Clamp(value.M42, min.M42, max.M42), Functions.Clamp(value.M13, min.M13, max.M13), Functions.Clamp(value.M23, min.M23, max.M23), Functions.Clamp(value.M33, min.M33, max.M33), Functions.Clamp(value.M43, min.M43, max.M43)));
 }
Beispiel #4
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 Matrix4x3f Max(Matrix4x3f value1, Matrix4x3f value2)
 {
     return(new Matrix4x3f(Functions.Max(value1.M11, value2.M11), Functions.Max(value1.M21, value2.M21), Functions.Max(value1.M31, value2.M31), Functions.Max(value1.M41, value2.M41), Functions.Max(value1.M12, value2.M12), Functions.Max(value1.M22, value2.M22), Functions.Max(value1.M32, value2.M32), Functions.Max(value1.M42, value2.M42), Functions.Max(value1.M13, value2.M13), Functions.Max(value1.M23, value2.M23), Functions.Max(value1.M33, value2.M33), Functions.Max(value1.M43, value2.M43)));
 }
Beispiel #5
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 Matrix4x3f Modulate(Matrix4x3f left, Matrix4x3f right)
 {
     return(new Matrix4x3f(left.M11 * right.M11, left.M21 * right.M21, left.M31 * right.M31, left.M41 * right.M41, left.M12 * right.M12, left.M22 * right.M22, left.M32 * right.M32, left.M42 * right.M42, left.M13 * right.M13, left.M23 * right.M23, left.M33 * right.M33, left.M43 * right.M43));
 }
Beispiel #6
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 Matrix4x3f Map(Matrix4x3f value, Func <float, float> mapping)
 {
     return(new Matrix4x3f(mapping(value.M11), mapping(value.M21), mapping(value.M31), mapping(value.M41), mapping(value.M12), mapping(value.M22), mapping(value.M32), mapping(value.M42), mapping(value.M13), mapping(value.M23), mapping(value.M33), mapping(value.M43)));
 }
Beispiel #7
0
 public static Matrix4x3f Negate(Matrix4x3f value)
 {
     return(new Matrix4x3f(-value.M11, -value.M21, -value.M31, -value.M41, -value.M12, -value.M22, -value.M32, -value.M42, -value.M13, -value.M23, -value.M33, -value.M43));
 }
Beispiel #8
0
 public static Matrix4x3f Divide(Matrix4x3f matrix, float scalar)
 {
     return(new Matrix4x3f(matrix.M11 / scalar, matrix.M21 / scalar, matrix.M31 / scalar, matrix.M41 / scalar, matrix.M12 / scalar, matrix.M22 / scalar, matrix.M32 / scalar, matrix.M42 / scalar, matrix.M13 / scalar, matrix.M23 / scalar, matrix.M33 / scalar, matrix.M43 / scalar));
 }
Beispiel #9
0
 public static Matrix4x4f Multiply(Matrix4x3f left, Matrix3x4f right)
 {
     return(new Matrix4x4f(left.M11 * right.M11 + left.M12 * right.M21 + left.M13 * right.M31, left.M21 * right.M11 + left.M22 * right.M21 + left.M23 * right.M31, left.M31 * right.M11 + left.M32 * right.M21 + left.M33 * right.M31, left.M41 * right.M11 + left.M42 * right.M21 + left.M43 * right.M31, left.M11 * right.M12 + left.M12 * right.M22 + left.M13 * right.M32, left.M21 * right.M12 + left.M22 * right.M22 + left.M23 * right.M32, left.M31 * right.M12 + left.M32 * right.M22 + left.M33 * right.M32, left.M41 * right.M12 + left.M42 * right.M22 + left.M43 * right.M32, left.M11 * right.M13 + left.M12 * right.M23 + left.M13 * right.M33, left.M21 * right.M13 + left.M22 * right.M23 + left.M23 * right.M33, left.M31 * right.M13 + left.M32 * right.M23 + left.M33 * right.M33, left.M41 * right.M13 + left.M42 * right.M23 + left.M43 * right.M33, left.M11 * right.M14 + left.M12 * right.M24 + left.M13 * right.M34, left.M21 * right.M14 + left.M22 * right.M24 + left.M23 * right.M34, left.M31 * right.M14 + left.M32 * right.M24 + left.M33 * right.M34, left.M41 * right.M14 + left.M42 * right.M24 + left.M43 * right.M34));
 }
Beispiel #10
0
 public static Matrix4x3f Multiply(Matrix4x3f matrix, float scalar)
 {
     return(new Matrix4x3f(matrix.M11 * scalar, matrix.M21 * scalar, matrix.M31 * scalar, matrix.M41 * scalar, matrix.M12 * scalar, matrix.M22 * scalar, matrix.M32 * scalar, matrix.M42 * scalar, matrix.M13 * scalar, matrix.M23 * scalar, matrix.M33 * scalar, matrix.M43 * scalar));
 }
Beispiel #11
0
 public static Matrix4x2f Multiply(Matrix4x3f left, Matrix3x2f right)
 {
     return(new Matrix4x2f(left.M11 * right.M11 + left.M12 * right.M21 + left.M13 * right.M31, left.M21 * right.M11 + left.M22 * right.M21 + left.M23 * right.M31, left.M31 * right.M11 + left.M32 * right.M21 + left.M33 * right.M31, left.M41 * right.M11 + left.M42 * right.M21 + left.M43 * right.M31, left.M11 * right.M12 + left.M12 * right.M22 + left.M13 * right.M32, left.M21 * right.M12 + left.M22 * right.M22 + left.M23 * right.M32, left.M31 * right.M12 + left.M32 * right.M22 + left.M33 * right.M32, left.M41 * right.M12 + left.M42 * right.M22 + left.M43 * right.M32));
 }
Beispiel #12
0
 public static Matrix4x3f Subtract(Matrix4x3f left, Matrix4x3f right)
 {
     return(new Matrix4x3f(left.M11 - right.M11, left.M21 - right.M21, left.M31 - right.M31, left.M41 - right.M41, left.M12 - right.M12, left.M22 - right.M22, left.M32 - right.M32, left.M42 - right.M42, left.M13 - right.M13, left.M23 - right.M23, left.M33 - right.M33, left.M43 - right.M43));
 }
Beispiel #13
0
 public static Matrix4x3f Add(Matrix4x3f left, Matrix4x3f right)
 {
     return(new Matrix4x3f(left.M11 + right.M11, left.M21 + right.M21, left.M31 + right.M31, left.M41 + right.M41, left.M12 + right.M12, left.M22 + right.M22, left.M32 + right.M32, left.M42 + right.M42, left.M13 + right.M13, left.M23 + right.M23, left.M33 + right.M33, left.M43 + right.M43));
 }
Beispiel #14
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 Matrix4x3f Round(Matrix4x3f value, int digits, MidpointRounding mode)
 {
     return(new Matrix4x3f(Functions.Round(value.M11, digits, mode), Functions.Round(value.M21, digits, mode), Functions.Round(value.M31, digits, mode), Functions.Round(value.M41, digits, mode), Functions.Round(value.M12, digits, mode), Functions.Round(value.M22, digits, mode), Functions.Round(value.M32, digits, mode), Functions.Round(value.M42, digits, mode), Functions.Round(value.M13, digits, mode), Functions.Round(value.M23, digits, mode), Functions.Round(value.M33, digits, mode), Functions.Round(value.M43, digits, mode)));
 }
Beispiel #15
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(Matrix4x3f value)
 {
     return(value.M11 != 0 || value.M21 != 0 || value.M31 != 0 || value.M41 != 0 || value.M12 != 0 || value.M22 != 0 || value.M32 != 0 || value.M42 != 0 || value.M13 != 0 || value.M23 != 0 || value.M33 != 0 || value.M43 != 0);
 }
Beispiel #16
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 Matrix4x3f Reciprocal(Matrix4x3f value)
 {
     return(new Matrix4x3f(1 / value.M11, 1 / value.M21, 1 / value.M31, 1 / value.M41, 1 / value.M12, 1 / value.M22, 1 / value.M32, 1 / value.M42, 1 / value.M13, 1 / value.M23, 1 / value.M33, 1 / value.M43));
 }
Beispiel #17
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(Matrix4x3f value, Predicate <float> predicate)
 {
     return(predicate(value.M11) || predicate(value.M21) || predicate(value.M31) || predicate(value.M41) || predicate(value.M12) || predicate(value.M22) || predicate(value.M32) || predicate(value.M42) || predicate(value.M13) || predicate(value.M23) || predicate(value.M33) || predicate(value.M43));
 }
Beispiel #18
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 Matrix3x4f Transpose(Matrix4x3f matrix)
 {
     return(new Matrix3x4f(matrix.M11, matrix.M12, matrix.M13, matrix.M21, matrix.M22, matrix.M23, matrix.M31, matrix.M32, matrix.M33, matrix.M41, matrix.M42, matrix.M43));
 }
Beispiel #19
0
 public static Matrix2x3f Multiply(Matrix2x4f left, Matrix4x3f right)
 {
     return(new Matrix2x3f(left.M11 * right.M11 + left.M12 * right.M21 + left.M13 * right.M31 + left.M14 * right.M41, left.M21 * right.M11 + left.M22 * right.M21 + left.M23 * right.M31 + left.M24 * right.M41, left.M11 * right.M12 + left.M12 * right.M22 + left.M13 * right.M32 + left.M14 * right.M42, left.M21 * right.M12 + left.M22 * right.M22 + left.M23 * right.M32 + left.M24 * right.M42, left.M11 * right.M13 + left.M12 * right.M23 + left.M13 * right.M33 + left.M14 * right.M43, left.M21 * right.M13 + left.M22 * right.M23 + left.M23 * right.M33 + left.M24 * right.M43));
 }