用插补的方法把"B样条曲线"进行插补输出到雕刻机进行刻绘?
<FONT color=#000000><FONT color=#000000>小弟在做AUTOCAD的图形输出。 <BR>我现在需要用插补的方法把"B样条曲线"进行插补输出到雕刻机进行刻绘。现在遇到困难。 <BR>我的算法如下: <BR>Dim n As Integer '样条曲线控制点数 <BR>Dim u(5), v(5) As Double 'x,y坐标 <BR><BR>Private Sub Command3_Click() <BR>Picture1.Scale (0, 0)-(800, 600) <BR>u(0) = 57: v(0) = Picture1.ScaleHeight - 83 <BR>u(1) = 190: v(1) = Picture1.ScaleHeight - 442 <BR>u(2) = 259: v(2) = Picture1.ScaleHeight - 5 <BR>u(3) = 461: v(3) = Picture1.ScaleHeight - 505 <BR>u(4) = 449: v(4) = Picture1.ScaleHeight - 123 <BR>n = 5 <BR><BR>b_spLine n <BR><BR>End Sub <BR><BR>Private Sub b_spLine(n As Integer) <BR>Dim i, j, k As Integer <BR>Dim b(4, 10), x(10), y(10) As Double <BR>num = 10 <BR>For i = 1 To 10 <BR>t = i / num <BR>b(0, i) = (1 - t) * (1 - t) * (1 - t) / 6 <BR>b(1, i) = (t - 2) * t * t / 2 + 2 / 3 <BR>b(2, i) = (1 + t - t * t) * t / 2 + 1 / 6 <BR>b(3, i) = t * t * t / 6 <BR>Next i <BR>For i = 1 To n <BR>x(i) = u(i - 1): y(i) = v(i - 1) <BR>Next i <BR><BR>x(0) = 2 * x(1) - x(2): y(0) = 2 * y(1) - y(2) <BR>x(n + 1) = 2 * x(n) - x(n - 1): y(n + 1) = 2 * y(n) - y(n - 1) <BR>Picture1.PSet (x(1), y(1)) <BR>For i = 0 To n - 2 <BR> For j = 1 To 10 <BR> xe = 0: ye = 0 <BR> For k = 0 To 3 <BR> xe = xe + b(k, j) * x(i + k): ye = ye + b(k, j) * y(i + k) <BR> Next k <BR> Picture1.Line -(xe, ye) <BR> Next j <BR>Next i <BR>End Sub <BR><BR>该算法是利用AUTOCAD的DXF文件中的控制点数据进行插补的,可是画出的图形与AUTOCAD中的图形不完全相同。望有经验的帮帮我,万分着急! <BR></FONT></FONT> Dim u(5), v(5) As Double 'x,y坐标 <BR>vb里这样定义好象是有问题的吧?
页:
[1]