how do you multiply two Matrix3x2 ?

Nov 29, 2013 at 10:24 AM
Hi, thanks for the wrapper it looks great so far. I'm usually a C++ person, don't know much about .Net and managed c++, and I can't figure how to multiply 2 Matrix3x2 together, the operator doesn't seem to be defined in D2Dcommon.h. I'm sure it's possible with the base D2D1 class though:
http://msdn.microsoft.com/en-us/library/windows/desktop/dd372282(v=vs.85).aspx

see also http://msdn.microsoft.com/en-us/library/windows/desktop/dd756672(v=vs.85).aspx

You say on the homepage of this project almost all D2D functions are covered so I guess I must be missing something since this is pretty basic stuff?
Nov 29, 2013 at 5:57 PM
I ended up adding this to the Matrix3x2 struct in D2DCommon.h, seems to be consistent with the existing programming style. please tell me if I'm making a mistake but it seems to work alright. I think it's weird to reimplement all this instead of making calls to the wrapped library, but I don't know anything about managed c++ and wrapper writing so...
    inline Matrix3x2 Mul(const Matrix3x2 %matrix)
        {
            Matrix3x2 result;

            result.SetProduct(*this, matrix);

            return result;
        }
        
    inline static Matrix3x2 Mul(const Matrix3x2 %a, const Matrix3x2 %b)
        {
        Matrix3x2 product;
            product._11 = a._11 * b._11 + a._12 * b._21;
            product._12 = a._11 * b._12 + a._12 * b._22;
            product._21 = a._21 * b._11 + a._22 * b._21;
            product._22 = a._21 * b._12 + a._22 * b._22;
            product._31 = a._31 * b._11 + a._32 * b._21 + b._31;
            product._32 = a._31 * b._12 + a._32 * b._22 + b._32;

        return product;
        }
    inline void SetProduct(const Matrix3x2 %a, const Matrix3x2 %b)
        {
            _11 = a._11 * b._11 + a._12 * b._21;
            _12 = a._11 * b._12 + a._12 * b._22;
            _21 = a._21 * b._11 + a._22 * b._21;
            _22 = a._21 * b._12 + a._22 * b._22;
            _31 = a._31 * b._11 + a._32 * b._21 + b._31;
            _32 = a._31 * b._12 + a._32 * b._22 + b._32;
        }
no operator overloading because I just learned that you cannot pass an operand to an overloaded operator by reference in C# so I settled with a Mul function that does the same thing;