/// <summary> /// Matrix-multiplication for a 3x4- and a 4x3 matrix. /// </summary> /// <param name="lhs"> /// Left-hand side of the multiplication. /// </param> /// <param name="rhs"> /// Right-hand side of the multiplication. /// </param> /// <returns> /// The matrix-product of <paramref name="lhs"><c>lhs</c></paramref> /// and <paramref name="rhs"><c>rhs</c></paramref>. /// </returns> public static Matrix3x3 Multiply(Matrix3x4 lhs, Matrix4x3 rhs) { const int m = Matrix3x4.Height; // Height of the product const int n = Matrix4x3.Width; // Width of the product const int o = Matrix3x4.Width; // Same as lhs.Height var product = new Matrix3x3(); for (int i = 0; i < m; ++i) { for (int j = 0; j < n; ++j) { var sum = 0f; for (int k = 0; k < o; ++k) { sum += lhs[i, k] * rhs[k, j]; } product[i, j] = sum; } } return(product); }
/// <summary> /// Matrix-multiplication of this and a 4x3 matrix. /// </summary> /// <param name="rhs"> /// Right-hand side of the multiplication. /// </param> /// <returns> /// The matrix-product of this matrix and /// <paramref name="rhs"><c>rhs</c></paramref>. /// </returns> public Matrix3x3 Multiply(Matrix4x3 rhs) { return(Multiply(this, rhs)); }