begin process at 2008 05 12 01:28:38
1 170 100 membres
5 nouveaux aujourd'hui
13 956 membres club

Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum.
Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !

ENSEMBLES MANDELBROT-JULIA


Information sur la source

Catégorie :Divers Classé sous : mandelbrot, julia, fractale Niveau : Débutant Date de création : 29/08/2005 Date de mise à jour : 29/08/2005 18:49:32 Vu : 3 122

Note :
10 / 10 - par 2 personnes
10,00 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10

Commentaire sur cette source (10)
Ajouter un commentaire et/ou une note

Description

Bon dans la serie snippets totalement inutiles je voudrais celui-là ;-)
Donc comme c'est ecrit dans le titre, ce snippet permet de tracer l'ensemble de mandelbrot (et celui de julia qui en resulte)
Vous devez commencer a avoir l'habitude, les calculs sont longs a s'effectuer , et plus vous choisirez une taille de fenetre importante ou un nombre d'iterations elevé , plus ce sera longs (plusieurs minutes)
En double-cliquant sur un point de mandel, le calcul de l'ensemble de julia va s'effectuer avec les meme propriétés que celles utilisées pour dessiner l'ensemble de mandel
Vous pouvez faire un zoom (bon ça n'est pas tout a fait au point) : pour cela faites un rectangle de selection et appuyez sur entrée
J'ai prevu de faire ce code sur d'autres language, mais j'ai voulu commencer a le faire avec mirc, pour le fun

avis au amateurs, ça peut toujours servir ;o)

Source

  • dialog mj {
  • title "Mandel & Julia"
  • size -1 -1 101 127
  • option dbu
  • box "Taille fenetre", 1, 5 2 88 39
  • text "Largeur :", 2, 13 13 31 8
  • edit "300", 3, 49 11 39 11,center
  • text "Hauteur :", 4, 13 28 31 8
  • edit "200", 5, 49 26 39 11,center
  • text "Nombre d'iterations :", 6, 11 92 52 8
  • edit "10", 7, 68 90 20 11,center
  • button "Lancer !", 8, 33 110 37 13
  • box "Options", 9, 6 45 88 61
  • text "Couleurs :", 10, 11 57 25 8
  • check "", 13, 11 72 9 10
  • text "Rafraichir la fenetre en temps réel", 14, 23 71 58 15
  • combo 11, 42 55 46 33, size drop
  • }
  • on *:dialog:mj:*:*:{
  • if ($devent == init) { didtok mj 11 44 Dégradé gris ,Jaune-Rouge }
  • elseif ($devent == sclick && $did == 8) {
  • set %ma_width $did(3) | set %ma_height $did(5) | set %ma_iter $did(7) | set %ma_n $iif($did(13).state,-r,-nr)
  • set %ma_color $iif(gris isin $did(11),$($rgb(%c,%c,%c),0),$($rgb(255,$calc(255 - %c),0),0))
  • set %ma_xmax 2 | set %ma_xmin -2 | set %ma_ymax 1.5 | set %ma_ymin -1.5
  • mandel
  • }
  • elseif ($devent == close) { if (window(@mandel)) close -@ @man* | if ($window(@julia)) close -@ @jul* | if ($hget(color)) hfree $v1 | unset %ma_* }
  • }
  • alias -l mandel {
  • window -pd +L @mandel -1 -1 %ma_width $calc(%ma_height + 21) | window -o @mandel
  • var %i 1 | while (%i <= %ma_iter) { hadd -m color %i $int($calc((%i - 1)*256 /(%ma_iter - 1))) | inc %i }
  • var %ticks $ticks | echo -a Calcul en cours...
  • var %dx $calc((%ma_xmax - %ma_xmin) / %ma_width) , %dy $calc((%ma_ymax - %ma_ymin) / %ma_height)
  • var %y %ma_ymin , %x %ma_xmin
  • var %py 0 | while (%py <= %ma_height) {
  • ;dll WhileFix.dll WhileFix
  • var %px 0 | while (%px <= %ma_width) {
  • var %zr 0 , %zi 0 , %i 1
  • while ($calc((%zr)^2 + (%zi)^2) < 4 && %i <= %ma_iter) {
  • var %temp %zr
  • var %zr $calc((%zr)^2 - (%zi)^2 + %x)
  • var %zi $calc(2 * %temp * %zi + %y)
  • inc %i
  • }
  • var %c $iif($hget(color,$calc(%i - 1)),$v1,0)
  • drawdot %ma_n @mandel $(%ma_color,2) 1 %px %py
  • inc %x %dx
  • inc %px
  • }
  • inc %y %dy
  • var %x %ma_xmin
  • inc %py
  • }
  • window -ph @man1 | dc @mandel @man1
  • echo -a Ensemble de Mandelbrot calculé en $duration($calc(($ticks - %ticks) / 1000)) , double-cliquez sur un point pour calculer l'ensemble de julia à ces coordonnées
  • }
  • alias -l julia {
  • window -pd +L @julia -1 -1 %ma_width $calc(%ma_height + 21) | window -o @julia
  • var %ticks $ticks | echo -a Calcul en cours...
  • var %dx $calc((%ma_xmax - %ma_xmin) / %ma_width) , %dy $calc((%ma_ymax - %ma_ymin) / %ma_height)
  • var %y %ma_ymin , %x %ma_xmin
  • var %py 0 | while (%py <= %ma_height) {
  • ;dll WhileFix.dll WhileFix
  • var %px 0 | while (%px <= %ma_width) {
  • var %zr %x , %zi %y , %i 1
  • while ($calc((%zr)^2 + (%zi)^2) < 4 && %i <= %ma_iter) {
  • var %temp %zr
  • var %zr $calc((%zr)^2 - (%zi)^2 + %ma_cx)
  • var %zi $calc(2 * %temp * %zi + %ma_cy)
  • inc %i
  • }
  • var %c $iif($hget(color,$calc(%i - 1)),$v1,0)
  • drawdot %ma_n @julia $(%ma_color,2) 1 %px %py
  • inc %x %dx
  • inc %px
  • }
  • inc %y %dy
  • var %x %ma_xmin
  • inc %py
  • }
  • window -ph @jul1 | dc @julia @jul1
  • echo -a Ensemble de Julia aux coordonnées %ma_cx + i * %ma_cy calculé en $duration($calc(($ticks - %ticks) / 1000))
  • }
  • menu @mandel {
  • sclick { set %ma_bool $mouse.x $mouse.y }
  • mouse { if (%ma_bool) { dc @man1 @mandel | drawrect -c @mandel 14 1 %ma_bool $calc($mouse.x - $gettok(%ma_bool,1,32)) $calc($mouse.y - $gettok(%ma_bool,2,32)) } }
  • drop {
  • if (%ma_bool != $mouse.x $mouse.y) {
  • tokenize 32 %ma_bool
  • if ($1 < $mouse.x && $2 < $mouse.y) { set %ma_xywh $1-2 $mouse.x $mouse.y } | elseif ($mouse.x > $1 && $mouse.y < $2) { set %ma_xywh $1 $mouse.y $mouse.x $2 }
  • elseif ($1 > $mouse.x && $2 < $mouse.y) { set %ma_xywh $mouse.x $2 $1 $mouse.y } | else { set %ma_xywh $mouse.x $mouse.y $1-2 }
  • }
  • unset %ma_bool
  • }
  • dclick { $cx($mouse.x,$mouse.y) | julia }
  • Enregistrer l'image:{ dc @man1 @mandel | sav @mandel }
  • }
  • menu @julia {
  • sclick set %ma_bool $mouse.x $mouse.y
  • mouse {
  • if (%ma_bool) { dc @jul1 @julia | drawrect -c @julia 14 1 %ma_bool $calc($mouse.x - $gettok(%ma_bool,1,32)) $calc($mouse.y - $gettok(%ma_bool,2,32)) } }
  • drop {
  • if (%ma_bool != $mouse.x $mouse.y) {
  • tokenize 32 %ma_bool
  • if ($1 < $mouse.x && $2 < $mouse.y) { set %ma_xywh $1-2 $mouse.x $mouse.y } | elseif ($mouse.x > $1 && $mouse.y < $2) { set %ma_xywh $1 $mouse.y $mouse.x $2 }
  • elseif ($1 > $mouse.x && $2 < $mouse.y) { set %ma_xywh $mouse.x $2 $1 $mouse.y } | else { set %ma_xywh $mouse.x $mouse.y $1-2 }
  • }
  • unset %ma_bool
  • }
  • Enregistrer l'image:{ dc @jul1 @julia | sav @julia }
  • }
  • alias -l s2c {
  • var %limx $calc($abs(%ma_xmin) + $abs(%ma_xmax)) , %limy $calc($abs(%ma_ymin) + $abs(%ma_ymax))
  • tokenize 32 $1
  • set %ma_xmin $calc(%ma_xmin + ((%limx * $1) / %ma_width))
  • set %ma_xmax $calc(%ma_xmin + ((%limx * $3) / %ma_width))
  • set %ma_ymin $calc(%ma_ymin + ((%limy * $2) / %ma_height))
  • set %ma_ymax $calc(%ma_ymin + ((%limy * $4) / %ma_height))
  • }
  • alias -l cx {
  • var %limx $calc($abs(%ma_xmin) + $abs(%ma_xmax)) , %limy $calc($abs(%ma_ymin) + $abs(%ma_ymax))
  • set %ma_cx $calc(%ma_xmin + ((%limx * $1) / %ma_width))
  • set %ma_cy $calc(%ma_ymin + ((%limy * $2) / %ma_height))
  • }
  • alias m&j dialog $iif($dialog(mj),-v,-m) mj mj
  • alias -l sav { var %img $+(",$$sfile($+($scriptdir,\*.bmp),Choissiez le répertoire et le nom de l'image qui va être sauvegardée,&Sauvegarder),") | drawsave $1 %img }
  • alias -l dc { drawcopy $1 0 0 $window($1).w $window($1).h $2 0 0 }
  • on *:keydown:@mandel:13:{ $s2c(%ma_xywh) | mandel }
  • on *:keydown:@julia:13:{ $s2c(%ma_xywh) | julia }
  • on *:close:@mandel: { hfree color | unset %ma_* | window -c @man1 | if ($window(@julia)) close -@ @jul* }
  • on *:close:@julia:window -c @jul1
dialog mj {
  title "Mandel & Julia"
  size -1 -1 101 127
  option dbu
  box "Taille fenetre", 1, 5 2 88 39
  text "Largeur :", 2, 13 13 31 8
  edit "300", 3, 49 11 39 11,center
  text "Hauteur :", 4, 13 28 31 8
  edit "200", 5, 49 26 39 11,center
  text "Nombre d'iterations :", 6, 11 92 52 8
  edit "10", 7, 68 90 20 11,center
  button "Lancer !", 8, 33 110 37 13
  box "Options", 9, 6 45 88 61
  text "Couleurs :", 10, 11 57 25 8
  check "", 13, 11 72 9 10
  text "Rafraichir la fenetre en temps réel", 14, 23 71 58 15
  combo 11, 42 55 46 33, size drop
}

on *:dialog:mj:*:*:{ 
  if ($devent == init) { didtok mj 11 44 Dégradé gris ,Jaune-Rouge }
  elseif ($devent == sclick && $did == 8) {
    set %ma_width $did(3) | set %ma_height $did(5) | set %ma_iter $did(7) | set %ma_n $iif($did(13).state,-r,-nr)
    set %ma_color $iif(gris isin $did(11),$($rgb(%c,%c,%c),0),$($rgb(255,$calc(255 - %c),0),0))
    set %ma_xmax 2 | set %ma_xmin -2 | set %ma_ymax 1.5 | set %ma_ymin -1.5
    mandel
  }
  elseif ($devent == close) { if (window(@mandel)) close -@ @man* | if ($window(@julia)) close -@ @jul* | if ($hget(color)) hfree $v1 | unset %ma_* }
}

alias -l mandel {
  window -pd +L @mandel -1 -1 %ma_width $calc(%ma_height + 21) | window -o @mandel
  var %i 1 | while (%i <= %ma_iter) { hadd -m color %i $int($calc((%i - 1)*256 /(%ma_iter - 1))) | inc %i }
  var %ticks $ticks | echo -a Calcul en cours...
  var %dx $calc((%ma_xmax - %ma_xmin) / %ma_width) , %dy $calc((%ma_ymax - %ma_ymin) / %ma_height)
  var %y %ma_ymin , %x %ma_xmin
  var %py 0 | while (%py <= %ma_height) {
    ;dll WhileFix.dll WhileFix
    var %px 0 | while (%px <= %ma_width) {
      var %zr 0 , %zi 0 , %i 1
      while ($calc((%zr)^2 + (%zi)^2) < 4 && %i <= %ma_iter) {
        var %temp %zr
        var %zr $calc((%zr)^2 - (%zi)^2 + %x)
        var %zi $calc(2 * %temp * %zi + %y)
        inc %i
      }
      var %c $iif($hget(color,$calc(%i - 1)),$v1,0)
      drawdot %ma_n @mandel $(%ma_color,2) 1 %px %py
      inc %x %dx
      inc %px
    }
    inc %y %dy 
    var %x %ma_xmin
    inc %py
  }
  window -ph @man1 | dc @mandel @man1
  echo -a Ensemble de Mandelbrot calculé en $duration($calc(($ticks - %ticks) / 1000)) , double-cliquez sur un point pour calculer l'ensemble de julia à ces coordonnées
}

alias -l julia {
  window -pd +L @julia -1 -1 %ma_width $calc(%ma_height + 21) | window -o @julia
  var %ticks $ticks | echo -a Calcul en cours...
  var %dx $calc((%ma_xmax - %ma_xmin) / %ma_width) , %dy $calc((%ma_ymax - %ma_ymin) / %ma_height)
  var %y %ma_ymin , %x %ma_xmin
  var %py 0 | while (%py <= %ma_height) {
    ;dll WhileFix.dll WhileFix
    var %px 0 | while (%px <= %ma_width) {
      var %zr %x , %zi %y , %i 1
      while ($calc((%zr)^2 + (%zi)^2) < 4 && %i <= %ma_iter) {
        var %temp %zr
        var %zr $calc((%zr)^2 - (%zi)^2 + %ma_cx)
        var %zi $calc(2 * %temp * %zi + %ma_cy)
        inc %i
      }
      var %c $iif($hget(color,$calc(%i - 1)),$v1,0)
      drawdot %ma_n @julia $(%ma_color,2) 1 %px %py
      inc %x %dx
      inc %px
    }
    inc %y %dy 
    var %x %ma_xmin
    inc %py
  }
  window -ph @jul1 | dc @julia @jul1
  echo -a Ensemble de Julia aux coordonnées %ma_cx + i * %ma_cy calculé en $duration($calc(($ticks - %ticks) / 1000))
}

menu @mandel {
  sclick { set %ma_bool $mouse.x $mouse.y }
  mouse { if (%ma_bool) { dc @man1 @mandel | drawrect -c @mandel 14 1 %ma_bool $calc($mouse.x - $gettok(%ma_bool,1,32)) $calc($mouse.y - $gettok(%ma_bool,2,32)) } }
  drop { 
    if (%ma_bool != $mouse.x $mouse.y) { 
      tokenize 32 %ma_bool
      if ($1 < $mouse.x && $2 < $mouse.y) { set %ma_xywh $1-2 $mouse.x $mouse.y } |  elseif ($mouse.x > $1 && $mouse.y < $2) {  set %ma_xywh $1 $mouse.y $mouse.x $2 } 
      elseif ($1 > $mouse.x && $2 < $mouse.y) { set %ma_xywh $mouse.x $2 $1 $mouse.y } | else { set %ma_xywh $mouse.x $mouse.y $1-2 } 
    }
    unset %ma_bool 
  } 
  dclick { $cx($mouse.x,$mouse.y) | julia }
  Enregistrer l'image:{ dc @man1 @mandel | sav @mandel }
}

menu @julia {
  sclick set %ma_bool $mouse.x $mouse.y 
  mouse {
  if (%ma_bool) { dc @jul1 @julia | drawrect -c @julia 14 1 %ma_bool $calc($mouse.x - $gettok(%ma_bool,1,32)) $calc($mouse.y - $gettok(%ma_bool,2,32)) } }
  drop { 
    if (%ma_bool != $mouse.x $mouse.y) { 
      tokenize 32 %ma_bool
      if ($1 < $mouse.x && $2 < $mouse.y) { set %ma_xywh $1-2 $mouse.x $mouse.y } |  elseif ($mouse.x > $1 && $mouse.y < $2) {  set %ma_xywh $1 $mouse.y $mouse.x $2 } 
      elseif ($1 > $mouse.x && $2 < $mouse.y) { set %ma_xywh $mouse.x $2 $1 $mouse.y } | else { set %ma_xywh $mouse.x $mouse.y $1-2 } 
    }
    unset %ma_bool 
  } 
  Enregistrer l'image:{ dc @jul1 @julia | sav @julia }
}

alias -l s2c {
  var %limx $calc($abs(%ma_xmin) + $abs(%ma_xmax)) , %limy $calc($abs(%ma_ymin) + $abs(%ma_ymax))
  tokenize 32 $1
  set %ma_xmin $calc(%ma_xmin + ((%limx * $1) / %ma_width))
  set %ma_xmax $calc(%ma_xmin + ((%limx * $3) / %ma_width))
  set %ma_ymin $calc(%ma_ymin + ((%limy * $2) / %ma_height))
  set %ma_ymax $calc(%ma_ymin + ((%limy * $4) / %ma_height))
}

alias -l cx {
  var %limx $calc($abs(%ma_xmin) + $abs(%ma_xmax)) , %limy $calc($abs(%ma_ymin) + $abs(%ma_ymax))
  set %ma_cx $calc(%ma_xmin + ((%limx * $1) / %ma_width))
  set %ma_cy $calc(%ma_ymin + ((%limy * $2) / %ma_height))
}

alias m&j dialog $iif($dialog(mj),-v,-m) mj mj
alias -l sav { var %img $+(",$$sfile($+($scriptdir,\*.bmp),Choissiez le répertoire et le nom de l'image qui va être sauvegardée,&Sauvegarder),")  | drawsave $1 %img }
alias -l dc { drawcopy $1 0 0 $window($1).w $window($1).h $2 0 0 }
on *:keydown:@mandel:13:{ $s2c(%ma_xywh) | mandel }
on *:keydown:@julia:13:{ $s2c(%ma_xywh) | julia }
on *:close:@mandel: { hfree color | unset %ma_* | window -c @man1 | if ($window(@julia)) close -@ @jul* }
on *:close:@julia:window -c @jul1 

Conclusion

/m&j pour l'utiliser

(il est vrai que j'aurai plus ne faire qu'un seul alias regroupant mendel et julia, mais pour la compréhension, c'est plus clair ainsi)
29 août 2005 18:49:32 :
trompé de catégorie
  • signaler à un administrateur
    Commentaire de Nostrow le 29/08/2005 23:26:30

    Si tu pouvais expliquer ce qu'est Mandelbrot et Julia :D Je ne vois pas du tout ce que c'est. Sinon j'aime ce genre d'add-on pourtant inaproprié à mIRC ^^ En tout cas y'a du travail :)

    P.S: J'attends de savoir ce que c'est exactement le Mandelbrot et Julia pour mettre une note ^^

  • signaler à un administrateur
    Commentaire de fjxokt le 29/08/2005 23:39:32

    http://fr.wikipedia.org/wiki/Ensemble_de_Mandelbrot

    ;-)

  • signaler à un administrateur
    Commentaire de KiNdErMaXi le 30/08/2005 18:48:09

    tin ca fait me ramer :|

  • signaler à un administrateur
    Commentaire de KiNdErMaXi le 30/08/2005 18:49:04

    ca me fait ramer* dsl

  • signaler à un administrateur
    Commentaire de fjxokt le 30/08/2005 19:21:13

    j'avais prévenu :p
    disons qu'il ne faut pas depasser les 50 iterations avec des fenetre de taille superieur a 300 * 200 (environ)

  • signaler à un administrateur
    Commentaire de punk6_2 le 30/08/2005 22:53:03

    J'ai cherché a comprendre se que c'était le Mandelbrot et Julia même avec ton site :/ C'est trop compliquer pour les petits :D

  • signaler à un administrateur
    Commentaire de KiNdErMaXi le 31/08/2005 02:16:40

    apparament c'est une formule de maths

  • signaler à un administrateur
    Commentaire de PaDa le 01/09/2005 23:35:43

    Mandlebrot et Julia sont des matheux qui ont bossé sur des ensembles fractales : en gros, les formules qu'ils ont étudié permettent de dessiner un ensemble, et quel que soit le zoom appliqué à cet ensemble, c'est jamais vraiment "lisse" , le motif se répète a l'infini (c'est l'idée des fractales...)
    Voir : http://fr.wikipedia.org/wiki/Fractale , qui est ptet plus mieux bien. (moins technique)

    Niveau fractales/mirc :
    Deux trois de moi ^^ (une famille nommée les IFS) : http://www.tismania.org/snippets.php?id=1461
    La plus "simple" : http://www.scriptsdb.org/comments.php?id=483 (version récursive, j'peux vous fournir mon code, itératif, moins joli)
    Et je mets la un vieux truc de sax, je pense pas qu'il m'en voudra, c'était en tagX ya qq mois sur sdb
    http://pada.exolia.net/fractsax.mrc

  • signaler à un administrateur
    Commentaire de fjxokt le 02/09/2005 00:45:45

    bon moi qui voulais faire le flocon de koch, c'est rapé , on m'a devancé ;)
    sinon c'est tres interressant ce que tu as fait pada, va falloir que je trouve autre chose moi :)
    (j'ai pas eu la patience d'attendre la fin du calcul, mais le snippet de sax et le mien doivent etre assez similaires)

  • signaler à un administrateur
    Commentaire de PaDa le 02/09/2005 03:28:53

    cui de sax de mémoire faut bien attendre 45/50 mins pour avoir un résultat potable
    dsl pour le flocon ^^

Ajouter un commentaire

Appels d'offres

Pub



Snippets en rapport

CalendriCode

Mai 2008
LMMJVSD
   1234
567891011
12131415161718
19202122232425
262728293031 

Boutique

Boutique de goodies CodeS-SourceS