, Visual C#


         


.
41.2.
.
' :
Private Sub FindPointOnCurve(ByRef x As Single, _
ByRef y As Single, ByVal LevelCurves As Single, _
Optional ByVal start_x As Single = 0.1, _
Optional ByVal start_y As Single = 0.2, _
Optional ByVal tolerance As Single = 0.01, _
Optional ByVal initial_delta As Single = 0.1)
Dim dx As Single : Dim dy As Single
Dim dz As Single : Dim dist As Single
Dim delta As Single : Dim f_xy As Single
Dim direction As Integer
' :
x = start_x : y = start_y : delta = initial_delta
' :
Do
f_xy = f(x, y) : dz = LevelCurves - f_xy
If Abs(dz) < tolerance Then Exit Do
' :
If Sign(dz) <> direction Then
' . delta:
delta = delta / 2 : direction = Sign(dz)
End If
' :
Gradient(x, y, dx, dy)
If Abs(dx) + Abs(dy) < 0.001 Then Exit Do
' :
x = x + dx * delta * direction
y = y + dy * delta * direction
Loop
End Sub
' :
Private Sub Gradient(ByVal x As Single, _
ByVal y As Single, ByRef dx As Single, ByRef dy As Single)
Dim dist As Single
dx = df_dx(x, y) : dy = df_dy(x, y)
dist = CSng(Sqrt(dx * dx + dy * dy))
If Abs(dist) < 0.0001 Then
dx = 0 : dy = 0
Else
dx = dx / dist : dy = dy / dist
End If
End Sub
' :
' myArrayVB_2(i, j):
Dim N_x_2 As Integer = 20000
Dim N_y_2 As Integer = 1
' myArrayVB_2(i, j) Single ,