glm 中乘法和求逆运算的结果
// 5 6 * 1 3 // 2 4 glm::vec2 x(5, 6); glm::mat2 m(1, 2, 3, 4); //memory locates 1 2 3 4 too printf("X: %.2f %.2f\n", x[0], x[1]); printMat2(m, "M"); glm::vec2 y0 = x * m; glm::vec2 y1 = m * x; printf("X * M = %.2f %.2f\n", y0[0], y0[1]); printf("M * X = %.2f %.2f\n", y1[0], y1[1]); m = glm::inverse(m); printMat2(m, "M_inverse");
打印结果:
X: 5.00 6.00 M :000000098DD6F7C0 1.0000000 2.0000000 3.0000000 4.0000000 X * M = 17.00 39.00 M * X = 23.00 34.00 M_inverse :000000098DD6F7E0 -2.0000000 1.0000000 1.5000000 -0.5000000
注意: 如果有一个矩阵如此声明, glm::mat2 m(1, 2, 3, 4);
实际上, 矩阵并不是长这样 1 2 \n 3 4, 实际上是 1 3 \n 2 4, m[0] == 1 2 m[1] = 3 4 , 这样做的主要原因是为了加速计算
X * M 实际上不是 X * M 而是 XT * M
标签:%.,glm,printf,2f,vec2,库中,排布,y1 From: https://www.cnblogs.com/luoyinjie/p/16833576.html