Attribute VB_Name = "Module2"
'DEMO Set of Julia
' J-P Moreau
Const bord = 100
Public incx As Double, incy As Double, P As Double, Q As Double
Public x1 As Double, x2 As Double, y1 As Double, y2 As Double
Public limite As Integer
Dim compt As Integer
Dim module As Double, x As Double, y As Double
Dim aux As Double, xx As Double, yy As Double
'***************************************************************************
'* FRACTALS: SET OF JULIA *
'* ----------------------------------------------------------------------- *
'* TUTORIAL: *
'* *
'* PRELIMINARY: THE SET OF MANDELBROT (see program mandel.pas) *
'* *
'* The set of Mandelbrot is a figure in the complex plane, that is (for no *
'* mathematicians) the plane allowing to represent complex numbers having *
'* the form a + i b, a is the real part (ox componant) and b is the *
'* imaginary part (oy componant). The imaginary number i is the unity of *
'* axis oy, defined as i x i = -1. In the following, we will use the *
'* multiplication of two complex numbers and the module value of a complex *
'* number before defining the set of Mandelbrot itself. *
'* *
'* Multiply z1 by z2 *
'* *
'* Let be z1 = a1 + i b1 and z2 = a2 + i b2, two complex numbers. To cal- *
'* culate Z = z1 x z2, one just has to algebraically develop the expression*
'* (a1 + i b1)*(a2 + i b2), replacing i² by -1 and sepatating constant *
'* terms from i terms. One easily obtains: *
'* *
'* Z = (a² - b²) + i (2ab) *
'* *
'* Module of a complex number *
'* *
'* Every complex number a + i b can be represented as the point of coordi- *
'* nates (a, b) in the complex plane. Its module is nothing other than the *
'* distance of this point from origin (0,0), that is to say: *
'* *
'* | Z | = square root of (a² + b²) *
'* *
'* We can now define the iterative process that will lead us to the magni- *
'* ficent "Set of Mandelbrot": *
'* *
'* We take, as a starting point, a fixed complex number c, and we calculate*
'* the complex expression z² + c, z being a variable complex number. *
'* Let us take z = 0, then z² + c equals c. Let us replace z by c in the *
'* formula z² + c, then we obtain c² + c. Let us again remplace z by this *
'* new value, then we obtain (c²+c)² + c. Such a process is indefinitly *
'* resumed, each new value z² + c is taken as new value z. This provides *
'* an unlimited series of z numbers. *
'* *
'* The mathematician Mandelbrot was the first to notice that, according to *
'* the chosen value c, the series of complex numbers z so obtained could *
'* have a module, either rapidly tending towards infinity, or tending *
'* towards a finite value, whatever the number of iterations may be. *
'* *
'* Two examples: *
'* *
'* 1) c = 1 + i *
'* *
'* iteration new z module of z *
'* ____________________________________________ *
'* 1 1 + 3i 3,16227... *
'* 2 -7 + 7i 9,89949... *
'* 3 1-97i 97,00515... *
'* 4 -9407-193i 9408,97965 *
'* *
'* The module of z increases very rapidly. *
'* *
'* 2) c = -1 + 0,25 i *
'* *
'* iteration new z module de z *
'* ____________________________________________ *
'* 1 -0,5 - 0i 0,5 *
'* 2 -0,25 + 0,5i 0,55902... *
'* 3 -0,687 + 0,25i 0,73154... *
'* *
'* At 80th iteration, z = 0.40868 + 0,27513 i, the module equals 0,49266...*
'* The module remains with a finite value, whatever the number of itera- *
'* tions may be. Practically, we will consider that the limit is obtained *
'* after 100 iterations, if the module of z is < 4. The set of Mandelbrot, *
'* still called the Mandelbrot man, because of its shape, is constituted *
'* by all the points for which the expression z² + c has a finite value *
'* whatever the number of iterations may be. *
'* *
'* *
'* SET OF JULIA *
'* *
'* If you take as a rule to fix the value of complex number c and to make *
'* vary the starting value of complex number z, you define a new set, *
'* different from the previous set of Mandelbrot, called Set of Julia, *
'* after the name of a french mathematician who studied it first. Each new *
'* c value injected into the iterative formula z² + c generates a new set *
'* of Julia which are in unlimited amount. These sets of Julia can have *
'* amazingly different forms according to the starting value. *
'* *
'* If the starting point c is chosen inside the main body of the Mandelbrot*
'* man, then the corresponding set of Julia is in one single part. *
'* According to other possible starting points, the set of Julia can have *
'* the form of an infinity of so called fractal circles, or a "dendritic" *
'* line (with many ramifications), or can be composed of several parts. *
'* At the limit, if c is far away from the Mandelbrot man's body, the set *
'* of Julia is reduced to a "dust" of points, called "Fatou's dust" after *
'* the name of another french mathematician. *
'* *
'* The program asks for the following parameters: *
'* *
'* x1, x2: interval for ox axis *
'* y1, y2: interval for oy axis *
'* Lim : maximum number of iterations *
'* p, q : coordinates of starting point c *
'* *
'* Some interesting examples: *
'* *
'* (Dragon shape) *
'* x1 = -1.5 x2 = 1.5 *
'* y1 = -1.5 y2 = 1.5 Lim = 200 *
'* p = 0.32 q = 0.043 *
'* *
'* (Jewel shape) *
'* x1 = -1.8 x2 = 1.8 *
'* y1 = -1.8 y2 = 1.8 Lim = 200 *
'* p = -0.74543 q = 0.11301 *
'* *
'* (cactus shape) *
'* x1 = -1.4 x2 = 1.4 *
'* y1 = -1.4 y2 = 1.4 Lim = 200 *
'* p = -0.12 q = 0.74 *
'* *
'* Up to you to discover other ones ! *
'* ----------------------------------------------------------------------- *
'* REFERENCE: *
'* "Graphisme dans le plan et dans l'espace avec Turbo Pascal 4.0 *
'* By R. Dony - MASSON, Paris 1990" [BIBLI 12]. *
'* *
'* Visual Basic release by J-P Moreau *
'* (to be used with gr2d.bas and Julia.Frm) *
'* (www.jpmoreau.fr) *
'***************************************************************************
Sub Julia()
Donnees
Form1.AutoRedraw = False
Form1.Cls
Fenetre x1, x2, y1, y2
cloture bord, MaxX - bord, bord, MaxY - bord
Bordure
Display 300, 300, "Set of Julia"
ch$ = "x1=" & CStr(x1) & " x2=" & CStr(x2) & " y1=" & CStr(y1)
ch$ = ch$ & " y2=" & CStr(y2) & " p=" & CStr(P) & " q=" & CStr(Q) & " Lim=" & CStr(limite)
Display 2000, 5600, ch$
xx = x1
Do While xx <= x2
yy = y1
Do While yy <= 0
compt = 0
module = 0
x = xx: y = yy
Do While (compt <= limite) And (module <= 4)
aux = x
x = x * x - y * y + P
y = 2 * y * aux + Q
module = x * x + y * y
compt = compt + 1
Loop
If module <= 4 Then
MoveXY -xx, -yy
LineXY -xx + incx, -yy
MoveXY xx, yy
LineXY xx + incx, yy
End If
yy = yy + incy
Loop
xx = xx + incx
Loop
End Sub
Sub Donnees()
x1 = -1.5: x2 = 1.5
y1 = -1.5: y2 = 1.5
limite = 100
P = 0.32: Q = 0.043
MaxX = 8300: MaxY = 6000
incx = 10 * (x2 - x1) / MaxX
incy = 10 * (y2 - y1) / MaxY
End Sub