Arithmetic
矩阵基本的运算
mat2 m = mat2(1, 2,
3, 4);
mat2 w = mat2(7, 8,
9, 10);
//Component wise addition
mat2 h = m + w;
//Now: h = mat2(8, 10,
// 12, 14)
//Scalar multiplication
mat2 j = 2.0 * m;
//Now: j = mat2(2, 4,
// 6, 8)
Instead, the * operator has the effect of multiplying matrices and transforming vectors:
mat2 m = mat2(1, 2,
3, 4);
vec2 v = m * vec2(1, 2); //v = vec2(7, 10)
//In GLSL, switching order of arguments is equivalent
//to transposing:
vec2 u = vec2(1, 2) * m; //u = vec2(5, 11)