貝賽爾曲線的定義
貝塞爾曲線(bézier curve)是由法國雷諾公司的設計師pierre bézier設計。它的具體定義如下:
其中pi(i=0,1,2,...n)稱作曲線的控制向量,他們組成的連續多段線叫做曲線的控制多邊形; t ∈[0,1],即 t 從0連續變化到1時所生成的曲線就叫做貝賽爾曲線。而函式:
叫做貝塞爾基函式(bézier basis functions),也叫做伯恩斯坦多項式(bernstein polynomials)它的定義如下:
其中n!=1*2*3*...*n 即n的階乘函式。
參考:bezier曲線的生成演算法
在 介紹了乙個生成bezier曲線上點的演算法:
實現的**
以下是在autocad 2011 x64 中實現的**,其他版本大同小異(vba實現):
sub bezier()
dim i as long, j as long, m as long, n as long
dim coor as variant, bezierps() as double, p(2) as double
dim t as double, s as double, deltat as double
dim selecpoly as acadselectionset
dim pointobj as acadpoint, bezierl as acadpolyline
dim pointid(10000000) as double
'delete all selection sets
i = 0
do while thisdrawing.selectionsets.count > 0
thisdrawing.selectionsets.item(i).delete
i = i + 1
loop
'select a polyline in your drawing
set selecpoly = thisdrawing.selectionsets.add("controlpoly")
selecpoly.selectonscreen
'draw vertices of the bezier curve
deltat = 0.001
i = j = m = 0
n = ubound(selecpoly.item(0).coordinates) - 1
do while t <= 1 + deltat
s = 1 - t
coor = selecpoly.item(0).coordinates
for i = 1 to n / 2
for j = 0 to n - 2 * i step 2
coor(j) = s * coor(j) + t * coor(j + 2)
coor(j + 1) = s * coor(j + 1) + t * coor(j + 3)
next
next
p(0) = coor(0): p(1) = coor(1): p(2) = 0
set pointobj = thisdrawing.modelspace.addpoint(p)
pointobj.visible = true
pointid(m) = pointobj.objectid32'store the objectids of points
for i = 0 to m - 1
set pointobj = thisdrawing.objectidtoobject32(pointid(i))
pointobj.delete
next
end sub
下面是生成的曲線效果圖:
貝塞爾曲線的生成
貝塞爾曲線的動態圖 該 包含了簡單的一階二階三階曲線的公式.貝塞爾曲線可以表示如下 b t i 0nc in 1 t n iti pib t sum c i 1 t t ip i b t i 0 n cin 1 t n itip i 其中 cin n i n i c i n frac cin i n...
貝塞爾曲線上一點
計算bezier曲線上的點,可用bezier曲線方程,但使用de casteljau提出的遞推算法則要簡單得多。如圖3.1.10所示,設p0 p02 p 2是一條拋物線上順序三個不同的點。過p0和p 2點的兩切線交於p1 點,在p02 點的切線交p0p 1和p2p 1於p01 和p11,則如下比例成...
貝塞爾曲線生成演算法
從網上蒐集來的兩控制點貝塞爾曲線生成法 int n controlpoint.size 1 vector儲存控制點 int i,r float u cvpoint p new cvpoint n 1 bezierpoint.clear u的步長決定了曲線點的精度 for u 0 u 1 u 0.01...