- 积分
- 362
- 明经币
- 个
- 注册时间
- 2004-7-29
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
小弟在做AutoCAD的图形输出。 我现在需要用插补的方法把"B样条曲线"进行插补输出到雕刻机进行刻绘。现在遇到困难。 我的算法如下: Dim n As Integer '样条曲线控制点数 Dim u(5), v(5) As Double 'x,y坐标
Private Sub Command3_Click() Picture1.Scale (0, 0)-(800, 600) u(0) = 57: v(0) = Picture1.ScaleHeight - 83 u(1) = 190: v(1) = Picture1.ScaleHeight - 442 u(2) = 259: v(2) = Picture1.ScaleHeight - 5 u(3) = 461: v(3) = Picture1.ScaleHeight - 505 u(4) = 449: v(4) = Picture1.ScaleHeight - 123 n = 5
b_spLine n
End Sub
Private Sub b_spLine(n As Integer) Dim i, j, k As Integer Dim b(4, 10), x(10), y(10) As Double num = 10 For i = 1 To 10 t = i / num b(0, i) = (1 - t) * (1 - t) * (1 - t) / 6 b(1, i) = (t - 2) * t * t / 2 + 2 / 3 b(2, i) = (1 + t - t * t) * t / 2 + 1 / 6 b(3, i) = t * t * t / 6 Next i For i = 1 To n x(i) = u(i - 1): y(i) = v(i - 1) Next i
x(0) = 2 * x(1) - x(2): y(0) = 2 * y(1) - y(2) x(n + 1) = 2 * x(n) - x(n - 1): y(n + 1) = 2 * y(n) - y(n - 1) Picture1.PSet (x(1), y(1)) For i = 0 To n - 2 For j = 1 To 10 xe = 0: ye = 0 For k = 0 To 3 xe = xe + b(k, j) * x(i + k): ye = ye + b(k, j) * y(i + k) Next k Picture1.Line -(xe, ye) Next j Next i End Sub
该算法是利用AUTOCAD的DXF文件中的控制点数据进行插补的,可是画出的图形与AUTOCAD中的图形不完全相同。望有经验的帮帮我,万分着急!
|
|