/// <summary> /// Multiplies the <paramref name="lhs"/> matrix by the <paramref name="rhs"/> matrix. /// </summary> /// <param name="lhs">The LHS matrix.</param> /// <param name="rhs">The RHS matrix.</param> /// <returns>The product of <paramref name="lhs"/> and <paramref name="rhs"/>.</returns> public static Matrix2f operator *(Matrix2f lhs, Matrix2f rhs) { Matrix2f tempM = new Matrix2f(0); tempM[0][0] = (lhs[0][0] * rhs[0][0]) + (lhs[0][1] * rhs[1][0]); tempM[1][0] = (lhs[1][0] * rhs[0][0]) + (lhs[1][1] * rhs[1][0]); tempM[0][1] = (lhs[0][0] * rhs[0][1]) + (lhs[0][1] * rhs[1][1]); tempM[1][1] = (lhs[1][0] * rhs[0][1]) + (lhs[1][1] * rhs[1][1]); return(tempM); }
public static Matrix2f Inverse(Matrix2f m) { float OneOverDeterminant = (1f) / ( +m[0][0] * m[1][1] - m[1][0] * m[0][1]); Matrix2f inverse = new Matrix2f( +m[1][1] * OneOverDeterminant, -m[0][1] * OneOverDeterminant, -m[1][0] * OneOverDeterminant, +m[0][0] * OneOverDeterminant); return(inverse); }
public static Matrix2f Transpose(Matrix2f m) { Vector2f[] vec = new Vector2f[2]; vec[0] = new Vector2f(m[0]); vec[1] = new Vector2f(m[1]); for (int i = 0; i < 2; i++) { for (int j = 0; j < vec.Length; j++) { m[i][j] = vec[j][i]; } } return(m); //var vec0 = new Vector2f(m[0]); //var vec1 = new Vector2f(m[1]); //m[0][0] = vec0[0]; //m[0][1] = vec1[0]; //m[1][0] = vec0[1]; //m[1][1] = vec1[1]; //return m; }