gl-matrix icon indicating copy to clipboard operation
gl-matrix copied to clipboard

mat3 multiply with mat2d

Open mariusGundersen opened this issue 7 years ago • 1 comments

It would be useful to have a method for multiplying a mat3 with a mat2d (and a mat2d with a mat3) to produce a mat3.

mariusGundersen avatar Apr 22 '17 13:04 mariusGundersen

This in an imlementation for mat3:


function mul2d(out : mat3, a : mat2d, b : mat3) {

    var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5],

        b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5], b6 = b[6], b7 = b[7], b8 = b[8];

    out[0] = a0 * b0 + a2 * b1;

    out[1] = a1 * b0 + a3 * b1;

    out[2] = b2;

    out[3] = a0 * b3 + a2 * b4;

    out[4] = a1 * b3 + a3 * b4;

    out[5] = b5;

    out[6] = a0 * b6 + a2 * b7 + a4;

    out[7] = a1 * b6 + a3 * b7 + a5;

    out[8] = b8;

    return out;

};

mariusGundersen avatar Apr 22 '17 23:04 mariusGundersen