/// <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; }
public static extern Matrix2 InvertMatrixByValue(Matrix2 matrix);
public static extern void InvertMatrixByPtr(ref Matrix2 matrix);
/// <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); }
/// <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)); }