« Fractales » : différence entre les versions
Aller à la navigation
Aller à la recherche
Ligne 53 : | Ligne 53 : | ||
bi = y | bi = y | ||
DO | DO | ||
tmp = a | |||
a = a * a + b * b + c | a = a * a + b * b + c | ||
bi = 2 * | bi = 2 * tmp * bi + di | ||
zbar = a * a + bi * bi | zbar = a * a + bi * bi | ||
i = i + 1 | i = i + 1 | ||
Ligne 72 : | Ligne 73 : | ||
di = y | di = y | ||
DO | DO | ||
tmp = a | |||
a = a * a + b * b + c | a = a * a + b * b + c | ||
bi = 2 * | bi = 2 * tmp * bi + di | ||
zbar = a * a + bi * bi | zbar = a * a + bi * bi | ||
i = i + 1 | i = i + 1 |
Version du 25 octobre 2006 à 19:20
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 :
c = -0.7 d = -0.1 WHILE x < WIDTH WHILE y < HEIGHT a = x bi = y DO tmp = a a = a * a + b * b + c bi = 2 * tmp * 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
Et pour Mandelbrot (à tester)...:
a = 0 bi = 0 WHILE x < WIDTH WHILE y < HEIGHT c = x di = y DO tmp = a a = a * a + b * b + c bi = 2 * tmp * 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