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) {
扫描二维码关注公众号,回复:
11427254 查看本文章
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;
},