Private Sub Euler(ByVal f As Array, ByVal U As Array, ByVal Steps As Single, ByVal SimTime As Double, ByVal m1 As Double, ByVal m2 As Double, ByVal k1 As Double, ByVal k2 As Double, ByVal b1 As Double, ByVal b2 As Double) Dim x1 As Array = Array.CreateInstance(GetType(Double), CInt(Steps)) Dim x2 As Array = Array.CreateInstance(GetType(Double), CInt(Steps)) Dim v As Array = Array.CreateInstance(GetType(Double), CInt(Steps)) ' pochodna U Dim v1 As Array = Array.CreateInstance(GetType(Double), CInt(Steps)) 'pochodna x1 Dim v2 As Array = Array.CreateInstance(GetType(Double), CInt(Steps)) 'pochodna x2 x1(0) = 0 x2(0) = 0 v(0) = 0 v1(0) = 0 v2(0) = 0 Dim h As Double = SimTime / Steps Dim v1new, x1new As Double Dim v2new, x2new As Double Dim vnew As Double For i As Integer = 0 To CInt(Steps - 2) v1new = v1(i) + h * (k1 / m1 * (x2(i) - x1(i)) + b1 / m1 * (v2(i) - v1(i)) + f(i)) x1new = x1(i) + h * v1(i) v2new = v2(i) + h * (k1 / m2 * (x2(i) - x1(i)) + b1 / m2 * (v1(i) - v2(i)) + k2 / m2 * (U(i) - x2(i)) + b2 / m2 * (v(i) - v2(i))) x2new = x2(i) + h * v2(i) vnew = v(i) + h * U(i) v1(i + 1) = v1new x1(i + 1) = x1new v2(i + 1) = v2new x2(i + 1) = x2new v(i) = vnew Next Dim HTab As Array = Array.CreateInstance(GetType(Double), CInt(Steps)) Dim HTab2 As Array = Array.CreateInstance(GetType(Double), CInt(Steps)) Dim n As Integer n = 0 Rysuj(PictureBox2, x1, HTab2, CInt(Steps), h, SimTime, n) n = 1 Rysuj(PictureBox2, x2, HTab, CInt(Steps), h, SimTime, n) Tabela(x1, x2, f, U, Steps) Dim fuckyou As Bitmap = PictureBox3.Image fuckyou.Save("as1.bmp", System.Drawing.Imaging.ImageFormat.Bmp) PictureBox3.Image.Save("as2.bmp", System.Drawing.Imaging.ImageFormat.Bmp) End Sub Private Sub Rysuj(ByVal e As PictureBox, ByVal Arr As Array, ByVal H As Array, ByVal Steps As Integer, ByVal TimeStep As Double, ByVal SimTime As Double, ByVal n As Integer) Dim g As Graphics = Graphics.FromImage(e.Image) 'Dim g As Graphics = e.CreateGraphics 'Dim j As Dim kk As Double H = Arr.Clone Array.Sort(H) Dim MaxArr As Double = H.GetValue(CInt(Steps - 1)) Dim MinArr As Double = H.GetValue(0) If Math.Abs(MinArr) > MaxArr Then kk = MinArr g.DrawString(CStr(MinArr), Font3, Brushes.Red, xPos + 12, yPos + (yRectSize + 10) * n + 120) kk = Math.Abs(MinArr) g.DrawLine(Pens.Red, xPos + 8, yPos + (yRectSize + 10) * n + 15 + 120, xPos + 12, yPos + (yRectSize + 10) * n + 15 + 120) Else kk = Math.Abs(MaxArr) g.DrawString(CStr(MaxArr), Font3, Brushes.Red, xPos + 12, yPos + (yRectSize + 10) * n) g.DrawLine(Pens.Red, xPos + 8, yPos + (yRectSize + 10) * n + 15, xPos + 12, yPos + (yRectSize + 10) * n + 15) End If If kk = 0 Then kk = 1 End If For k As Integer = 0 To CInt(Steps - 2) If Arr(k + 1) > 10000000000 Then k = CInt(Steps - 3) MsgBox("Overflow") End If g.DrawLine(Pens.Blue, CInt(xPos + 10 + k * TimeStep * xRectSize / SimTime), CInt(yPos + (yRectSize + 10) * n + yRectSize / 2 - Arr(k) * 120 / kk), CInt(xPos + 10 + (k + 1) * TimeStep * xRectSize / SimTime), CInt(yPos + (yRectSize + 10) * n + yRectSize / 2 - Arr(k + 1) / kk * 120)) Next k End Sub