surface=Array(x,y,z)
End Function
我输入之后,运行时出现(没定义变量n),怎么回事?王老师这本书真心看不懂作者: lorenzo13 时间: 2012-11-1 21:04
代码中间需要对各种常量定义啦,每段前加一点就可以运行了
Call Main()
Sub Main()
Dim n,m
n=30
m=90
Dim pts()
ReDim pts(n*m-1)
Dim i,j,u,v
For i=0 To n-1
u=2*rhino.Pi*i/(n-1)
For j=0 To m-1
v=2*rhino.Pi*j/(m-1)
pts(i*m+j)=surface(u,v)
Next
Next
rhino
rhino.AddSrfPtGrid Array(n,m),pts
End Sub
Function surface(u,v)
Dim x,y,z
y=(2+cos(v/2)*sin(u)-sin(v/2)*sin(2*u))*cos(v)
z=sin(v/2)*sin(u)+cos(v/2)*sin(2*u)
x=(2+cos(v/2)*sin(u)-sin(v/2)*sin(2*u))*sin(v)
surface=Array(x,y,z)