Explain - Formula to curve through a control point

后端 未结 2 583
天涯浪人
天涯浪人 2020-12-18 02:57

I have a question regarding formula curving through a control point. As you know, HTML Canvas has quadraticCurveTo(x1, y1, x2, y2) with x1 and x2 b

相关标签:
2条回答
  • 2020-12-18 03:36

    Quadratic Bezier curve is described by equations:

    x(t) = x0 * (1-t)^2 + 2 * x1 * t * (1 - t) + x2 * t^2 (and similar for y(t)).

    If we apply parameter value t = 1/2 (in some way - middle of the curve), we will get your formula:

    x(t=1/2) = xt = x0 * 1/4 + 2 * x1 * 1/4 + x2 * 1/4

    then

    x1/2 = xt - (x0 + x2)/4

    x1 = 2 * xt - (x0 + x2)/2

    0 讨论(0)
  • 2020-12-18 03:48

    This is called a Spline. More to the point, it appears that they are using a Bezier Curve.

    0 讨论(0)
提交回复
热议问题