Draw a quadratic Bézier curve through three given points

前端 未结 3 940
抹茶落季
抹茶落季 2020-12-04 15:47

I have three points in 2D and I want to draw a quadratic Bézier curve passing through them. How do I calculate the middle control point (x1 and y1

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-04 16:43

    If you don't want the exact middle point, rather you want any value for t (0 to 1), the equation is:

    controlX = pointToPassThroughX/t - startX*t - endX*t;
    controlY = pointToPassThroughY/t - startY*t - endY*t;
    

    Of course, this will also work for the mid point, just set t to be 0.5. Simple! :-)

提交回复
热议问题