我在actionscript中创建了这个类,它返回bezier的一个给定点。我想要实现的是得到当前点的角度。我在网上找了一下,但没找到多少。我该怎么做呢?
public static function quadraticBezierPoint(u:Number, anchor1:Point, anchor2:Point, control:Point):Point {
var uc:Number = 1 - u;
var posx:Number = Math.pow(uc, 2) * anchor1.x + 2 * uc * u * control.x + Math.pow(u, 2) * anchor2.x;
var posy:Number = Math.pow(uc, 2) * anchor1.y + 2 * uc * u * control.y + Math.pow(u, 2) * anchor2.y;
return new Point(posx, posy);
}发布于 2013-06-11 16:50:09
在Kevin的解释之后,我做了一个动态但简单的解决方案:
public static function quadraticBezierAngle(u:Number, anchor1:Point, anchor2:Point, control:Point):Number {
var uc:Number = 1 - u;
var dx:Number = (uc * control.x + u * anchor2.x) - (uc * anchor1.x + u * control.x);
var dy:Number = (uc * control.y + u * anchor2.y) - (uc * anchor1.y + u * control.y);
return Math.atan2(dy, dx);
}https://stackoverflow.com/questions/12357200
复制相似问题