1:角度弧度互转
radians = degree*Math.PI/180;
degree = radians *180/Math.PI;
2:向鼠标(或者任意一点)旋转
dx = mouse.x-obj.x;
dy = mouse.y-obj.y;
obj.totation = Math.atan2(dy,dx)*180/Math.PI;
3:创建波
value = centerx+Math.sin(angel)*rang;
angel+=speed(speed大小以0.1位步长);
4:创建园型路径
xposition = centerX +Math.cos(angel)*radius(r 为半径);
yposition = centerY +Math.sin(angel)*radius(r 为半径);
angel+=speed;
5:创建椭圆路径
xposition = centerX +Math.cos(angel)*radiusx(radiusx长半径);
yposition = centerY +Math.sin(angel)*radiusy(radiusy 为短半径);
angel+=speed;
6:获取两点之间的距离
dx = mouse.x-obj.x;
dy = mouse.y-obj.y;
dist = Math.sqrt(dx*dx+dy*dy);
时间: 2024-11-03 21:15:43