- 注册时间
- 2013-2-13
- 最后登录
- 2023-10-13
- 阅读权限
- 200
- 积分
- 9313
- 精华
- 1
- 帖子
- 2411
|
陈前帆 发表于 2013-11-29 12:51
/**
* 此类在 core.js 中进行扩展,扩展自 lufylegend-1.7.7 : LPoint 类
* @class LPoint
LPoint的扩展,前两天还有朋友要求我扩展这个类呢
LPoint.interpolate计算过于复杂了,并且有逻辑错误- var pt1 = new LPoint(2,5);
- var pt2 = new LPoint(10,15);
- LPoint.interpolate(pt1,pt2,0);返回(0,0)
- LPoint.interpolate(pt1,pt2,1);返回(8,10)
复制代码 正确写法为- LPoint.interpolate = function(p1,p2,f){
- return new LPoint(p1.x+(p2.x-p1.x)*(1-f),p1.y+(p2.y-p1.y)*(1-f));
- };
复制代码 另外,LPoint.distance中,求平方的时候,不要用Math.pow,效率很低 |
|