示例#1
0
        /// <summary>
        /// Inverts a given by-reference <see cref="Matrix2"/>.
        /// </summary>
        /// <param name="matrix">The matrix.</param>
        public static void Invert(ref Matrix2 matrix)
        {
            // Calculate determinant over one
            float det = 1 / ((matrix.Row0.X * matrix.Row1.Y) - (matrix.Row0.Y * matrix.Row1.X));

            float tmpd = matrix.Row1.Y;

            // Swap d and a
            matrix.Row1.Y = matrix.Row0.X;
            matrix.Row0.X = tmpd;

            // Negate b and c
            matrix.Row0.Y = -matrix.Row0.Y;
            matrix.Row1.X = -matrix.Row1.X;

            // And multiply by the determinant modifier
            matrix.Row0.X *= det;
            matrix.Row0.Y *= det;
            matrix.Row1.X *= det;
            matrix.Row1.Y *= det;
        }
示例#2
0
 public static extern Matrix2 InvertMatrixByValue(Matrix2 matrix);
示例#3
0
 public static extern void InvertMatrixByPtr(ref Matrix2 matrix);
示例#4
0
 /// <summary>
 /// Inverts a given by-value <see cref="Matrix2"/>.
 /// </summary>
 /// <param name="matrix">The matrix.</param>
 /// <returns>The inverted matrix.</returns>
 public static Matrix2 Invert(Matrix2 matrix)
 {
     Invert(ref matrix);
     return(matrix);
 }
示例#5
0
 /// <summary>
 /// Determines componentwise equality for the current and another matrix.
 /// </summary>
 /// <param name="other">The other matrix.</param>
 /// <returns>true if the matrices are equal, otherwise, false.</returns>
 public bool Equals(Matrix2 other)
 {
     return(this.Row0.Equals(other.Row0) && this.Row1.Equals(other.Row1));
 }