首页 > 代码库 > 缓动公式

缓动公式

 

缓存公式

// 角度旋转dx = mouse.x - object.x;dy = mouse.y - object.y;object.rotation = Math.atan2(dy,dx)*180/Math.PI//平滑运动value = http://www.mamicode.com/center + Math.sin(angle)*range;angle += speed;//正圆运动x_position = centerX + Math.sin(angle)*radius;y_position = centerY + Math.cos(angle)*radius;angle += speed;//椭圆运动x_position = centerX + Math.cos(angle)*radiusX;y_position = centerY + Math.sin(angle)*radiusY;angle += speed;//两点间距离dx = x2 - x1;dy = y2 - y1;dist = Math.sqrt(dx*dx + dy*dy);//任意方向速度vx = speed * Math.cos(angle);vy = speed * Math.sin(angle);//任意方向加速度ax = force * Math.cos(angle);ay = force * Math.xin(angle);//改变速度vx += ax;vx += ay;//改变位置object.x += vx;object.y += vy;

 

缓动公式