开发者

JavaScript: Rotate Polys

My code doesn't work right:

function rotate(Points, Angle) {
    for (var i=0; i<Points.length;i++) {
        Points[i] = [Math.cos(Angle) * Points[i][0] - Math.sin(Angle) * Points[i][1], Math.sin(Angle) * Points[i][0] + Math.cos(Angle) * Points[i][1]];
    }
    return Points;
}


rotate([[0, 0], [50, 0], [25, 25]], 5);

I used the following: http://www.开发者_JAVA百科vb-helper.com/howto_rotate_polygon_points.html


cos and sin in most programming languages are in radians. Are you sure you want to rotate by 5 radians (= 286 degrees)?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜