Brief Introduction of Bezier Curve and Bspline: B-spline (1)

1.什么是B-spline

Bezier Curve的缺点主要是:

  • nonlocality,移动一个控制点会影响整条曲线
  • 高阶曲线,曲线离控制点很远

对此,可以把N条Bezier Curve组合起来。如下图所示,是两条3次Bezier Curve在D点连接而得。

此时,该曲线是一条C0曲线,共有7个控制点。若想得到一条C1曲线,则需要两条Bezier Curve在D点的导数相同。通过Bezier Curve的导数表达式,可知需要C,D,E点共线并且|CD|=|DE|。此时D点失去了控制作用,共用6个控制点,如下图所示。

进一步地,若想得到一条C2曲线,则需要D点的二阶导数相同。那么此时需要又一个控制点失去作用,例如E点,如下图所示。

可见,N条3阶Bezier Curve拼接成一条C0曲线,需要4N(N1)=3N+1个控制点;一条C1曲线需要3N+1(N1)=2N+2个控制点;一条C2曲线需要2N+2(N1)=N+3个控制点。

进而,N条k阶的Bezier Curve拼接成一条Ck1连续的B-spline曲线需要N+k个控制点。

但值得注意的是,在上图中,A,B,C,F,G并不是B-spline的控制点,控制点应该是下图的S0-S4

B-spline具有局部性,例如移动S0,并不会对第二段Bezier Curve产生影响。同样地,移动S4,也不会对第一段Bezier Curve产生影响。B-spline的性质可总结为

  • The curve starts and ends at the first and last control vertices. 
  • The curve is tangent to the first and last edges of its control polygon. 
  • The B-spline curve is contained in the convex hull of its control polygon. 如下图所示。
  • If the B-spline curve is of degree n, it is contained in the union of the convex hulls of every n+1 consecutive vertices. 如下图所示。

 

  • The shape of the B-spline curve is roughly the same as the shape of its control polygon.
  • The B-spline curve twists less than its control polygon. 如下图所示。

  • Moving a vertex of the control polygon affects only a part of the curve close to the vertex moved.
  • The B-spline curve can be translated, rotated or reflected, by translating, rotating, or reflecting the vertices of its control polygon.

2.B-spline表达式

由N条k阶的Bezier Curve组成k阶B-spline曲线有N+k个控制点。B-spline的表达式可以写为:

BS(t)=i=0N+k1PiBi,k(t)   t[0,N]   (1)

当N=3,k=3时,对应的6个基函数如下图所示。

可见,基函数B0,3的有效区间,即值不为零的区间是[0,1],基函数B1,3的有效区间是[0,2]。

The knots of a B-spline curve are the endpoints of the supports of the basis functions that define the curve. 这6个基函数的knots为: suppB0,3=[0,1]suppB1,3=[0,2]suppB2,3=[0,3]suppB3,3=[0,3]suppB4,3=[1,3]suppB5,3=[2,3]

The knot vector comprises the knots of the basis functions that define a S-spline curve, listed from smallest to largest. 上方B-spline对应的knot vector为V={0,0,0,0,1,2,3,3,3,3}

N条k阶Bezier Curve组成的k阶B-spline曲线对应的knot vector为:

3.Cox-de boor formula

要想根据控制点生成B-spline,需要计算出相应的基函数。本小节就是一种用knot vector递归计算出基函数的算法。以上方的3阶B-spline为例,他的思想就是通过B0,0B1,0得到B0,1,以及通过B1,0B2,0得到B1,1,进而通过B0,1B1,1得到B0,2,如此递归地得到B0,3B5,3

计算公式如下: Bi,k(t)=tV[i]V[i+k]V[i]Bi,k1(t)+V[i+k+1]tV[i+k+1]V[i+1]Bi+1,k1(t)   (2) 并且 Bi,0(t)={1,   t[V[i],V[i+1])0,   otherwise   (3) 以及Bi,0=0  if V[i]=V[i+1],以及分母为0,则为0。

python代码详见:https://github.com/LiuLarissa/bezier_and_bspline_generator/blob/master/bspline_generator.py

4.B-spline的微分

针对B-spline如下的表达式: BS(t)=i=0NBi,k(t)Pi   (4) 基函数的一阶导数为: dBi,k(t)dt=Bi,k(t)=kti+ktiBi,k1(t)kti+k+1ti+1Bi+1,k1(t)   (5) 则B-spline的一阶导数为: BS(t)=ktkt0B0,k1(t)P0+ki=0n1Bi+1,k1(t)Pi+1Piti+k+1ti+1ktn+k+1tn+1Bn+1,k1(t)Pn   (6) 式(6)中的第一项和最后一项为0,则 BS(t)=i=0N1Bi+1,k1(t)Qi   (7)其中: Qi=kti+k+1ti+1(Pi+1Pi)   (8) 可见,一条k阶的B-spline的导数是另一条k-1阶的B-spline,控制点则变为了Q0,Q1,...Qn1,少了一个。针对这条k-1阶的B-spline,其knot vector就是之前的knot vector去掉第一个和最后一个元素。那么针对新的knot vector,B-spline的微分可以写为: BS(t)=i=0N1Bi,k1(t)Qi   (9)

posted @   南风小斯  阅读(134)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
· 三行代码完成国际化适配,妙~啊~
点击右上角即可分享
微信分享提示