您当前的位置: 首页 > 

鱼儿-1226

暂无认证

  • 0浏览

    0关注

    1100博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

cocoscreater 旋转角度计算

鱼儿-1226 发布时间:2020-07-23 10:25:26 ,浏览量:0

getVectorRadians( x1,  y1,  x2,  y2)

    {

        

        let len_y = y2 - y1;

        let len_x = x2 - x1;

 

        let tan_yx = tan_yx = Math.abs(len_y)/Math.abs(len_x);

        let angle = 0;

        if(len_y > 0 && len_x < 0) {

        angle = Math.atan(tan_yx)*180/Math.PI - 90;

        } else if (len_y > 0 && len_x > 0) {

        angle = 90 - Math.atan(tan_yx)*180/Math.PI;

        } else if(len_y < 0 && len_x < 0) {

        angle = -Math.atan(tan_yx)*180/Math.PI - 90;

        } else if(len_y < 0 && len_x > 0) {

        angle = Math.atan(tan_yx)*180/Math.PI + 90;

        }

        return angle;

    },

关注
打赏
1604459285
查看更多评论
立即登录/注册

微信扫码登录

0.0466s