Posted By

choppingblock on 02/24/13


Tagged

point calculate quadratic curve bezier


Versions (?)

Given Point Along Quadratic Bezier


 / Published in: ActionScript 3
 

Have a quadratic bezier curve, need to figure out a point along the way. This should work quite well, easy to convert to JavaScript.

  1. public static function quadraticBezierPoint(value:Number, anchor1:Point, anchor2:Point, control:Point):Point {
  2. var uc:Number = 1 - value;
  3. var posx:Number = Math.pow(uc, 2) * anchor1.x + 2 * uc * value * control.x + Math.pow(value, 2) * anchor2.x;
  4. var posy:Number = Math.pow(uc, 2) * anchor1.y + 2 * uc * value * control.y + Math.pow(value, 2) * anchor2.y;
  5. return new Point(posx, posy);
  6. }

Report this snippet  

You need to login to post a comment.