« Fractales » : différence entre les versions
Aller à la navigation
Aller à la recherche
Ligne 1 : | Ligne 1 : | ||
== Mandelbrot et Julia == | == Mandelbrot et Julia == | ||
=== Comment que l'on les calcule donc ? === | |||
Mandelbrot et Julia sont définies par la suite : | Mandelbrot et Julia sont définies par la suite : | ||
Ligne 32 : | Ligne 34 : | ||
<math>a_{n+1} = a_n^2 -b_n + c</math> et <math>bi_{n+1} = 2a_nbi_n + di</math> | <math>a_{n+1} = a_n^2 -b_n + c</math> et <math>bi_{n+1} = 2a_nbi_n + di</math> | ||
* le point Z appartient à la fractale | * le point Z appartient à la fractale si la longueur du vecteur Z (<math>\bar{z}</math> ne tend pas vers l'infini, il est dit un peu partout que si cette longueur dépasse 2, on va tendre vers l'infini... | ||
<math>\bar{z} = \sqrt{a^2 + b^2}</math> | <math>\bar{z} = \sqrt{a^2 + b^2}</math> | ||
Ligne 39 : | Ligne 41 : | ||
donc on peut juste tester <math>\bar{z} < a^2 + b^2</math> | donc on peut juste tester <math>\bar{z} < a^2 + b^2</math> | ||
=== Et hop, des chtis algorithmes === | |||
Pour dessiner la fractale '''Julia''' : | |||
WHILE x < WIDTH | |||
WHILE y < HEIGHT | |||
DO | |||
a = a * a + b * b + c | |||
bi = 2 * a * bi + di | |||
zbar = a * a + bi * bi | |||
i = i + 1 | |||
WHILE i < MAXITER) AND zbar < 4) | |||
IF zbar < 4: | |||
PIXEL(x, y) | |||
y = y + 1 | |||
x = x + 1 | |||
== Howtos == | == Howtos == | ||
* http://home.hia.no/~fgill/fractal.html | * http://home.hia.no/~fgill/fractal.html |
Version du 25 octobre 2006 à 17:46
Mandelbrot et Julia
Comment que l'on les calcule donc ?
Mandelbrot et Julia sont définies par la suite :
<math>Z_{n+1} = Z_n^2 + C</math>
- Z et C sont deux nombres complexes :
- <math>Z = a + bi</math>
- <math>C = c + di</math>
- Pour Mandelbrot C est le point à calculer :
- c est l'absisse
- di est l'ordonnée
- Pour Julia Z est le point à calculer :
- a est l'absisse
- bi est l'ordonnée
On aura donc :
<math>(a + bi)_{n+1} = (a_n + bi_n)^2 + c + di</math>
soit
<math>(a + bi)_{n+1} = a_n^2 +2a_nbi_n + (bi_n)^2 + c + di</math>
avec <math>i^2 = -1</math> ça donne
<math>(a + bi)_{n+1} = a_n^2 + 2a_nbi_n - b_n + c + di</math>
donc pour <math>n+1</math>:
<math>a_{n+1} = a_n^2 -b_n + c</math> et <math>bi_{n+1} = 2a_nbi_n + di</math>
- le point Z appartient à la fractale si la longueur du vecteur Z (<math>\bar{z}</math> ne tend pas vers l'infini, il est dit un peu partout que si cette longueur dépasse 2, on va tendre vers l'infini...
<math>\bar{z} = \sqrt{a^2 + b^2}</math>
on peut se passer de l'opération avec la racine carrée car <math>\sqrt{4} = 2</math>
donc on peut juste tester <math>\bar{z} < a^2 + b^2</math>
Et hop, des chtis algorithmes
Pour dessiner la fractale Julia :
WHILE x < WIDTH WHILE y < HEIGHT DO a = a * a + b * b + c bi = 2 * a * bi + di zbar = a * a + bi * bi i = i + 1 WHILE i < MAXITER) AND zbar < 4) IF zbar < 4: PIXEL(x, y) y = y + 1 x = x + 1