Attribute VB_Name = "Module2" '*************************************************************** '* BEAUTY OF CHAOS * '* ----------------------------------------------------------- * '* The two scientists Gumowski and Mira proposed in their * '* publications the following iterative model: * '* * '* x n+1 = b.y n + F(x n) * '* y n+1 = -x n + F(x n+1) * '* * '* with F(x) = a.x + (2(1-a)x²)/(1+x²) * '* * '* According to the value of parameters a and b, and the * '* coordinates of the starting point, the achieved drawing can * '* have a surprising beauty. * '* ----------------------------------------------------------- * '* Some interesting combinations: * '* a=0.1 b=0.99 x0=3 yy0=0 iter=30000 f1=-8 f2=8 f3=-6 f4=6 * '* a=0.01 b=0.96 x0=5 yy0=0 iter=25000 f1=-12 f2=12 f3=-8 f4=8 * '* a=0.32 b=1 x0=-5 yy0=0 iter=30000 f1=-16 f2=16 f3=-12 f4=12 * '* a=0.31 b=1 x0=12 yy0=0 iter=30000 f1=-40 f2=40 f3=-25 f4=25 * '* Can you find other ones ? * '* ----------------------------------------------------------- * '* From "Graphisme dans le plan et dans l'espace avec Turbo * '* Pascal 4.0 de R. Dony - MASSON 1990, page 198" * '* [BIBLI 12]. * '* * '* Visual Basic 4.0 release by J-P Moreau, Paris * '* (www.jpmoreau.fr) * '* * '* Uses: Mira.frm, Gr2d.bas * '*************************************************************** Public a As Double ' Sub Mira() Dim s As String * 60 Dim m As Integer, n As Integer, niter As Integer Dim x0 As Double, y0 As Double Dim x1 As Double, y1 As Double Dim b As Double, dx As Double, dy As Double 'data section (values may be changed by user) a = 0.31: b = 1#: x0 = 12#: y0 = 0#: niter = 32000 f1 = -40#: f2 = 40#: f3 = -25#: f4 = 25# Form1.AutoRedraw = False Form1.Cls Form1.Font.Bold = True Form1.Font.Size = 12 Display 700, 250, "CHAOS OF MIRA" Form1.Font.Bold = False Form1.Font.Size = 9 dx = (f2 - f1) / (MaxX - 200) dy = (f4 - f3) / (MaxY - 150) Fenetre f1, f2, f3, f4 cloture 100, MaxX - 100, 50, MaxY - 100 Bordure s = "a=" & Str$(a) & " b=" & Str$(b) & " x0=" & Str$(x0) & " y0=" & Str$(y0) & " niter=" & Str$(niter) Display 250, MaxY + 100, s 'main loop for chaos of mira For m = 1 To 3 For n = 1 To niter If x0 > f1 And x0 < f2 And y0 > f3 And y0 < f4 Then MoveXY x0, y0 LineXY x0 + 2 * dx, y0 + 2 * dy End If x1 = b * y0 + F(x0) y1 = F(x1) - x0 x0 = x1: y0 = y1 Next n Next m Form1.Command2.Caption = "Continue" End Sub 'Draw_Mira() Function F(ByVal x#) As Double F = a * x + (1# - a) * (2# * x * x / (1# + x * x)) End Function