疑惑了很久的旋转矩阵求值问题,求帮助

在 CCNode.js 中 _updateLocalMatrix ,关于旋转更新的部分
let a = 1, b = 0, c = 0, d = 1; // rotation if (hasRotation) { let rotationRadiansX = this._rotationX * ONE_DEGREE; c = Math.sin(rotationRadiansX); d = Math.cos(rotationRadiansX); if (this._rotationY === this._rotationX) { a = d; b = -c; } else { let rotationRadiansY = this._rotationY * ONE_DEGREE; a = Math.cos(rotationRadiansY); b = -Math.sin(rotationRadiansY); } }
在设计器中,Rotation 默认只有一个值,但是在代码中拆分成了 _rotationX 和 _rotationY。从2d的角度,此时应该是绕z轴旋转 ,所以我认为 a =cos b =-sin c=sin d=cos 但是,代码在else分支,就不理解了,无论带入 x 轴的旋转矩阵,还是带入 y 轴的旋转矩阵。得到的结果和代码匹配不上,知道的大佬,能否推导下
a = Math.cos(rotationRadiansY); b = -Math.sin(rotationRadiansY);
是怎么来的?

关于_rotationX和_rotationY,其实是同一个值,可能是要支持3d吧

rotation: {
...
            set (value) {
                if (this._rotationX !== value || this._rotationY !== value) {
                    this._rotationX = this._rotationY = value;
...
}

既然在2d情况下_rotationX===_rotationY,那么a=d=cos,b=-sin,c=sin。不是没问题吗

值一样的时候看的明白,不一样的时候 a b 就蒙了。从设计器角度, _rotationX 与 _rotationY 确实是相等。但是在代码里边我可以单独设置

update() {
this.node.rotationX++;

此时我用对应的旋转矩阵推导,就得不出对应代码的结果

是我没描述清楚么?为啥我推导不出来啊