程序代码
Dim pi As Double
pi = 4 * Atn(1)
Dim p(0 To 81) As Double
Dim myl As Object
j = 0
For i = -1 To 1 Step 0.05
p(j) = i * pi
p(j + 1) = Sin(p(j))
j = j + 2
Next i
Set myl = ThisDrawing.ModelSpace.AddLightWeightPolyline(p)
ZoomExtents
函数图的最后一个点跑到原点(0,0)位置了?
而把循环改成For i = 1 To 3 Step 0.05,图形却是正常的。
并且如果我在for循环之前,加上dim i as integer这一句,老是出现实时错误9,下标越界,这是为什么啊?
我又把for循环改成这样
For i = -pi To pi Step pi / 20
p(j) = i
p(j + 1) = sin(i)
j = j + 2
Next i
这样运行程序结果就对了。这个算法跟上面的不是一样的吗?