, Visual C#



41.1. Form1_Load.

' z = f = f(x, y):

Private Function f(ByVal x As Single, ByVal y As Single) _

As Single

f = 2 * x * x * x * x - 3 * x * x + 4 * y * y

End Function

' df/dx:

Private Function df_dx(ByVal x As Single, _

ByVal y As Single) As Single

df_dx = 8 * x * x * x - 6 * x

End Function

' df/dy:

Private Function df_dy(ByVal x As Single, _

ByVal y As Single) As Single

df_dy = 8 * y

End Function

' :

Private myPen As Pen

 

' :

Private Sub Form1_Load(ByVal sender As System.Object, _

ByVal e As EventArgs) Handles MyBase.Load

' :

myPen = New Pen(Color.Black, 0)

' PictureBox1

' g Graphics:

Dim bmp As New Bitmap(PictureBox1.ClientSize.Width, _

PictureBox1.ClientSize.Height)

Dim g As Graphics = Graphics.FromImage(bmp)

'

' PictureBox1

'-1.5 <= x <= 1.5, -1.5 <= y <= 1.5:

Const x_min As Single = -1.5

Const x_max As Single = 1.5

Const y_min As Single = -1.5

Const y_max As Single = 1.5

g.ScaleTransform(bmp.Width / (x_max - x_min), _

bmp.Height / (y_max - y_min))

g.TranslateTransform(-x_min, -y_min, _

System.Drawing.Drawing2D.MatrixOrder.Prepend)

' :

For LevelCurves As Integer = -3 To 10

PlotLevelCurve(g, CSng( _

LevelCurves / 4), -4, 4, -4, 4, 0.05, 1, 1, 0.002)

Next

' :

PictureBox1.Image = bmp

End Sub