如何计算贝塞尔曲线上的控制点?
我确实有一条贝塞尔曲线,并且在某一点上,我希望第二条贝塞尔曲线以平滑的方式分叉第一条曲线。连同计算交点(贝塞尔曲线后面的百分比),我还需要控制点(切线和重量)。
交叉点使用以下javascript计算:
I do have a bezier curve, and at a certain point, I want a second bezier curve "branching off" the first curve in a smooth manner. Together with calculating the intersection point (with a percentage following the Bezier curve), I need also the control point (the tangent and weight). The intersection point is calculated with the following piece of javascript:
getBezier = function getBez(percent,p1,cp1,cp2,p2) {
function b1(t) { return t*t*t }
function b2(t) { return 3*t*t*(1-t) }
function b3(t) { return 3*t*(1-t)*(1-t) }
function b4(t) { return (1-t)*(1-t)*(1-t) }
var pos = {x:0,y:0};
pos.x = p1.x*b1(percent) + cp1.x*b2(percent) + cp2.x*b3(percent) + p2.x*b4(percent);
pos.y = p1.y*b1(percent) + cp1.y*b2(percent) + cp2.y*b3(percent) + p2.y*b4(percent);
return pos;
}
(非IE浏览器可以在http:// www.iscriptdesign.com - >教程 - >组和路径)。
现在我需要的是分支点的控制点或(正切和重量)(我不知道从哪里开始,我希望有人可以指出一些代码或数学方程,如果可能的话,作为函数来自与上面的getBezier函数相同的参数。)
(Non IE browsers can see it in action at http://www.iscriptdesign.com -> Tutorial -> Groups & Paths). All I need now is the controlpoint or (tangent and weight) for the branchpoint ( I don't have a clue where to start, and I hope somebody can point to some code, or mathematical equation, if possible as function from the same parameters as the getBezier function above).
找到并实现它: de-Casteljau
算法被证明是最快的可实施解决方案。它目前存在于:
iScriptDesign (教程 - > Spit Bezier)。
Found and implemented it: de-Casteljau
algorithm turned out to be the fastest implementable solution. It is currently present under:
iScriptDesign (Tutorial ->Spit Bezier).