|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
下面是书上的关于等值线的程序源码(BASIC),总是看不明白,请高手指教!多谢
CONTZ: ' display isovalue contours
ZXO = 100: ZYO = 350: DZX = 400 / NX1: DZY = -200 / NY1
LINE (ZXO, ZYO)-(ZXO + NX1 * DZX, ZYO + NY1 * DZY), GW%, B, &HFFFF
XA = ZXO: YA = ZYO: XB = ZXO + (IXS - 1) * DZX: YB = ZYO + (IYS - 1) * DZY
Line (XA, YA)-(XB, YB), GW%, BF
ZMAX = -1000: ZMIN = 1000
For IX = 1 To NX: For IY = 1 To NY
If Z(IX, IY) > ZMAX Then ZMAX = Z(IX, IY)
If Z(IX, IY) < ZMIN Then ZMIN = Z(IX, IY)
Next IY: Next IX
IXP% = ZXO / 16: IYP% = ZYO / 16 + 1
LOCATE IYP%, 18:
Print USING; "Max. value=##.###^^^^ Min. value=##.###^^^^"; ZMAX; ZMIN;
ZMIN = 0: DZ = (ZMAX - ZMIN) / NZ
If DZ = 0 Then Return
For IX = 1 To NX1: For IY = 1 To NY1
XI = IX - 1: YI = IY - 1: XI1 = XI + 1: YI1 = YI + 1
N = 0
For K = 1 To NZ: GPK(K) = 0: GPX(K) = 0: GPY(K) = 0: Next K
Z1 = (Z(IX, IY) - ZMIN) / DZ
Z2 = (Z(IX, IY + 1) - ZMIN) / DZ
Z3 = (Z(IX + 1, IY + 1) - ZMIN) / DZ
Z4 = (Z(IX + 1, IY) - ZMIN) / DZ
K1 = Int(Z1): K2 = Int(Z2): K3 = Int(Z3): K4 = Int(Z4)
If K1 <> K2 Then
DZ1 = 1 / (Z2 - Z1)
KB = K1 + 1: KE = K2: If K1 > K2 Then KB = K2 + 1: KE = K1
For K = KB To KE
N = N + 1: GPK(N) = K: GPX(N) = XI * DZX + ZXO
GPY(N) = Int((YI + (K - Z1) * DZ1) * DZY + ZYO)
Next K
End If
N1 = N
If K2 <> K3 Then
DZ2 = 1 / (Z3 - Z2)
KB = K2 + 1: KE = K3: If K2 > K3 Then KB = K3 + 1: KE = K2
For K = KB To KE
N = N + 1: GPK(N) = K: GPY(N) = YI1 * DZY + ZYO
GPX(N) = Int((XI + (K - Z2) * DZ2) * DZX + ZXO)
Next K
End If
N2 = N
If K3 <> K4 Then
DZ3 = 1 / (Z3 - Z4)
KB = K3 + 1: KE = K4: If K3 > K4 Then KB = K4 + 1: KE = K3
For K = KB To KE
N = N + 1: GPK(N) = K: GPX(N) = XI1 * DZX + ZXO
GPY(N) = Int((YI + (K - Z4) * DZ3) * DZY + ZYO)
Next K
End If
N3 = N
If K4 <> K1 Then
DZ4 = 1 / (Z4 - Z1)
KB = K1 + 1: KE = K4: If K1 > K4 Then KB = K4 + 1: KE = K1
For K = KB To KE
N = N + 1: GPK(N) = K: GPY(N) = YI * DZY + ZYO
GPX(N) = Int((XI + (K - Z1) * DZ4) * DZX + ZXO)
Next K
End If
N4 = N
If K4 <> K2 Then
DZ5X = 1 / (Z2 - Z4): DZ5Y = 1 / (Z2 - Z4)
KB = K4 + 1: KE = K2: If K4 > K2 Then KB = K2 + 1: KE = K4
For K = KB To KE
N = N + 1: GPK(N) = K
GPX(N) = Int((XI1 - (K - Z4) * DZ5X) * DZX + ZXO)
GPY(N) = Int((YI + (K - Z4) * DZ5Y) * DZY + ZYO)
Next K
End If
N5 = N
For N = 1 To N1: For NN = N3 + 1 To N4
If GPK(N) = GPK(NN) Then
CL = GPK(N)
While CL > 7: CL = CL - 7: Wend
While CL < 1: CL = CL + 7: Wend
LINE (GPX(N), GPY(N))-(GPX(NN), GPY(NN)), GC%(CL), , &HFFFF
End If
Next NN: Next N
For N = N1 + 1 To N2: For NN = N2 + 1 To N3
If GPK(N) = GPK(NN) Then
CL = GPK(N)
While CL > 7: CL = CL - 7: Wend
While CL < 1: CL = CL + 7: Wend
LINE (GPX(N), GPY(N))-(GPX(NN), GPY(NN)), GC%(CL), , &HFFFF
End If
Next NN: Next N
For N = N4 + 1 To N5: For NN = 1 To N4
If GPK(N) = GPK(NN) Then
CL = GPK(N)
While CL > 7: CL = CL - 7: Wend
While CL < 1: CL = CL + 7: Wend
LINE (GPX(N), GPY(N))-(GPX(NN), GPY(NN)), GC%(CL), , &HFFFF
End If
Next NN: Next N
Next IY: Next IX
Return |
|