gpt4 book ai didi

c++ - 将高阶贝塞尔曲线拆分为多条三次曲线

转载 作者:行者123 更新时间:2023-11-28 00:16:29 28 4
gpt4 key购买 nike

我需要显示贝塞尔曲线。用户通过点击显示区域来选择任意点。

我实现了用这些点制作贝塞尔曲线的代码,但是对于高阶曲线它不起作用,一旦阶数等于控制点数 - 1。

我如何拆分这些控制点以生成代表我想要的整条曲线的三次贝塞尔曲线序列?

最佳答案

我相信您可以使用 adaptive methods 找到有关“绘制平滑贝塞尔曲线”的好资源,但我认为这是一个很好的简单方法(如果未优化的话):

  • 生成二项式系数。例如,5 次曲线可以表示为:

    Expanded Bezier polynomial

    二项式系数是帕斯卡三角的第 n 行:

    1, 5, 10, 10, 5, 1
  • 在连续划分对评估点产生显着变化的位置自适应地执行递归。这发生在尖点/急弯处,需要很多点才能收敛到可接受的解决方案。例如:

    Note that ||B(a) - B(b)|| is notation for the length
    of the line between the evaluated points B(a) and B(b).

    Evaluate B(t) for values of t = a, b, c, d, e
    = 0, 0.25, 0.5, 0.75, 1.

    Evaluate lengths of straight line segments:
    ac = ||B(a) - B(c)||
    ce = ||B(c) - B(e)||

    Also evaluate ab, bc, cd, de.

    if ac - (ab + bc) > ERROR_THRESHOLD
    Split ab into two segments and split bc into two segments.
    else
    We have found a good enough approximation.

    Do the same as above for ce - (cd + de).

关于c++ - 将高阶贝塞尔曲线拆分为多条三次曲线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29998038/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com