n-th order Bezier Curves?

前端 未结 2 1145
刺人心
刺人心 2021-02-13 13:26

I\'ve managed to implement quadratic and cubic Bezier curves.They are pretty straightforward since we have a formula. Now I want to represent an n-th order Bezier curve using th

2条回答
  •  一向
    一向 (楼主)
    2021-02-13 13:44

    The sum in your formula...

    enter image description here

    ...runs from 0 to n, ie for an n-th order bezier you need n+1 points.

    You have 4 points, so you're drawing a 3rd-order bezier.

    The error in your code is here:

    for(int j = 0; (unsigned int)j < nbPoint; j++)
    

    it should be:

    for(int j = 0; (unsigned int)j <= nbPoint; j++)
    

    otherwise you're only iterating from 0 to n-1.

    3rd-order bezier

    EDIT:

    Out of interest, the shape you were getting is the same as if the missing (5th) point was at (0,0), since that's the only point that would contribute nothing to your sum...

    4th-order bezier with 5th point at origin

提交回复
热议问题