math - Quadratic Bézier Curve: Calculate Points -
i'd calculate point on quadratic curve. use canvas element of html5.
when use quadraticcurveto() function in javascript, have source point, target point , control point.
how can calculate point on created quadratic curve @ let's t=0.5 "only" knowing 3 points?
use quadratic bézier formula, found, instance, on wikipedia page bézier curves:

in pseudo-code, that's
t = 0.5; // given example value x = (1 - t) * (1 - t) * p[0].x + 2 * (1 - t) * t * p[1].x + t * t * p[2].x; y = (1 - t) * (1 - t) * p[0].y + 2 * (1 - t) * t * p[1].y + t * t * p[2].y; p[0] start point, p[1] control point, , p[2] end point. t parameter, goes 0 1.
Comments
Post a Comment