I asked previously about the proper function for perspective (to compute and compose a matrix), now I'm facing an older problem and I wasn't expecting this to be so much of an issue still.
Basically 360deg / 720deg is just zero and I don't know how to hack the following function to fix that.
CSSMatrix.Rotate = function(rx, ry, rz){
rx *= Math.PI / 180;
ry *= Math.PI / 180;
rz *= Math.PI / 180;
// minus sin() because of right-handed system
var cosx = Math.cos(rx), sinx = - Math.sin(rx);
var cosy = Math.cos(ry), siny = - Math.sin(ry);
var cosz = Math.cos(rz), sinz = - Math.sin(rz);
var m = new CSSMatrix();
m.m11 = m.a = cosy * cosz;
m.m12 = m.b = -cosy * sinz;
m.m13 = siny;
m.m21 = m.c = sinx * siny * cosz + cosx * sinz;
m.m22 = m.d = cosx * cosz - sinx * siny * sinz;
m.m23 = - sinx * cosy;
m.m31 = sinx * sinz - cosx * siny * cosz;
m.m32 = sinx * cosz + cosx * siny * sinz;
m.m33 = cosx * cosy;
return m;
};
When using 360deg rotations (on any axis) to compose a matrix, the CSSMatrix.rotate()
method is creating a rotation matrix and for each angle value we get angle * Math.PI / 180
then other sinus / cosinus operations, but the matrix result is different from a computed transform of a regular rotateX(360deg)
.
See my fiddles here where same code doesn't work properly with 360deg angle and working properly with angles different from 360deg.
How can I fix that please?