Mr.*_*ieu 1 interpolation actionscript-3
我正在开发一个将一些源代码ActionScript 3转换为C#的项目.它具有以下功能:
Point.interpolate(Point p1, Point p2, Number distance)
Run Code Online (Sandbox Code Playgroud)
此功能的文档在这里.
我想问一下函数的算法是如何工作的.
正如文件所说:
参数f的值越接近1.0,插值点越接近第一点(参数pt1).参数f的值越接近0,插值点越接近第二点(参数pt2).
这可以这样实现:
public static function interpolate(pt1:Point, pt2:Point, f:Number):Point
{
var x:Number = f * pt1.x + (1 - f) * pt2.x;
var y:Number = f * pt1.y + (1 - f) * pt2.y;
return new Point(x, y);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2292 次 |
| 最近记录: |