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:

quadratic bezier formula

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

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -