1

Using jQuery I'm trying to obtain the rotation state of an object but in IE9 I can only return the matrix values. What I need is to change this into a single value as a degree.

4

2 回答 2

1

检查这篇文章:http ://css-tricks.com/get-value-of-css-rotation-through-javascript/

此函数将从矩阵值返回旋转角度:

function decodeMatrix(matrixValue){
    var values = matrixValue.split('(')[1];
        values = values.split(')')[0];
        values = values.split(',');
    var a = values[0];
    var b = values[1];
    var c = values[2];
    var d = values[3];
    var scale = Math.sqrt(a*a + b*b);
    var sin = b/scale;
    var angle = Math.round(Math.asin(sin) * (180/Math.PI));
    return angle;
}
于 2012-10-08T14:22:28.307 回答
1
函数解码矩阵(矩阵,查询){
    var values = matrix.split('(')[1];
    值 = values.split(')')[0];
    values = values.split(',');
    变量输出 = {
        一:值[0],
        b:值[1],
        c:值[2],
        d:值[3],
        x:值[4],
        y:值[5]
    };
    output.scale = Math.sqrt(output.aoutput.a + output.boutput.b);
    output.sin = output.b / output.scale;
    output.angle = Math.round(Math.asin(output.sin) * (180 / Math.PI));
    如果(查询){
        返回输出[查询];
    }
    返回输出;
}

于 2014-12-03T10:01:46.003 回答