Skip to content

Commit

Permalink
New function curveTangent(),bezierTangent()
Browse files Browse the repository at this point in the history
  • Loading branch information
dliu53 committed Dec 17, 2009
1 parent ef57baf commit dc9bc40
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions processing.js
Expand Up @@ -1726,7 +1726,7 @@ function buildProcessing( curElement ){

p.curve = function curve(x1, y1, x2, y2, x3, y3, x4, y4) {

p.beginShape();
p.beginShape();
p.curveVertex(x1, y1);
p.curveVertex(x2, y2);
p.curveVertex(x3, y3);
Expand All @@ -1737,11 +1737,16 @@ function buildProcessing( curElement ){

p.bezierPoint = function bezierPoint(a,b,c,d,t){
return (1-t)*(1-t)*(1-t)*a+3*(1-t)*(1-t)*t*b+3*(1-t)*t*t*c+t*t*t*d;
}
p.bezierTangent = function bezierTangent(a,b,c,d,t){
return -3*(1-t)*(1-t)*a+3*(1-2*t)*b+3*(2*t-3*t*t)*c+2*t*d;
}
p.curvePoint = function curvePoint(a,b,c,d,t){
return 0.5*((2*b)+(-a+c)*t+(2*a-5*b+4*c-d)*t*t+(-a+3*b-3*c+d)*t*t*t)
}

p.curveTangent = function curveTangent(a,b,c,d,t){
return 0.5*((-a+c)+2*(2*a-5*b+4*c-d)*t+3*(-a+3*b-3*c+d)*t*t)
}

//end

Expand Down

0 comments on commit dc9bc40

Please sign in to comment.