tbrosman/hxmath

Matrix3x2.concat incorrectly computes the last column

tbrosman opened this issue · 0 comments

Should be:

[M t] [N u]   [MN Mu + t]
[0 1] [0 1] = [ 0    1  ]

Currently is:

    @:op(A * B)
    public static function concat(m:Matrix3x2, n:Matrix3x2):Matrix3x2
    {
        // TODO: speed this up if it becomes an issue
        var mLinear:Matrix2x2 = m.linearSubMatrix;
        var nLinear:Matrix2x2 = n.linearSubMatrix;
        var resultLinear:Matrix2x2 = mLinear * nLinear;
        var resultAffine:Vector2 = nLinear * new Vector2(m.tx, m.ty) + new Vector2(n.tx, n.ty);
        
        return new Matrix3x2(
            resultLinear.a, resultLinear.b,
            resultLinear.c, resultLinear.d,
            resultAffine.x, resultAffine.y);
    }
[M t] [N u]   [MN Nt + u]
[0 1] [0 1] = [ 0    1  ]