Home › Forums › Games202-高质量实时渲染 › 作业资料 & 代码勘误 › Reply To: 作业资料 & 代码勘误
作业 2
还是觉得tools.js的mat4Matrix2mathMatrix函数有问题,glmatrix的mat4是按列优先存储的,但mat4Matrix2mathMatrix读的时候是按行优先存储读的,mat4Matrix2mathMatrix返回的是原矩阵的转置
打印了一下结果也确实是转置了:
let v = mat4.create();
mat4.fromRotation(v, math.pi / 6, [0, 1, 0]);
let v_ = mat4Matrix2mathMatrix(v);
console.log(v_);
0.8660253882408142, 0, -0.5, 0
0, 1, 0, 0
0.5, 0, 0.8660253882408142, 0
0, 0, 0, 1
但是实际旋转矩阵应该是
0.8660253882408142, 0, 0.5, 0
0, 1, 0, 0
-0.5, 0, 0.8660253882408142, 0
0, 0, 0, 1