[Enseignement] objet fractal à faire apparaître progressivement

Samuel Gougeon sgougeon at free.fr
Ven 4 Juil 21:19:04 CEST 2014


Bonjour,

Le 04/07/2014 12:18, Jean-François PIETRI a écrit :
> Bonjour,
>
> Le programme ci-dessous permet d'obtenir le dragon de Heighway, mais 
> je regrette qu'il arrive d'un bloc.
> Comme je me lance à peine avec scilab, quelqu'un pourrait-il me dire 
> comment le modifier pour que le dragon apparaisse progressivement en 
> 30 secondes par exemple.
Voici une possible mise en oeuvre :

function  point_image=transformation(point_antecedent,choix)
     if  choix  ==  1  then
         A  =  [[0.5,-0.5];[0.5,0.5]]  ;  V=[0;0];
     end
     if  choix  ==  2  then
         A  =  [[-0.5,-0.5];[0.5,-0.5]]  ;  V=[1;0];
     end

     point_image  =  A  *  point_antecedent  +  V

endfunction

nPoints  =  6000;
P  =  zeros(2,nPoints);
clf
plot(0,0,"*b")
c  =  gce();
c.parent.data_bounds  =  [-0.4,-0.4;1.2  0.7];
c  =  c.children;
for  i  =  2:nPoints
     tirage  =  rand();
     if  tirage  <  0.5  then  choix  =  1;
     else  choix  =  2;
     end
     tmp  =  transformation(P(:,i-1),choix);// P(:,i) est la colonne numéro i
     c.data($+1,:)  =  tmp.';
     P(:,i)  =  tmp;
end


-------------- section suivante --------------
Une pièce jointe HTML a été nettoyée...
URL: <https://lists.scilab.org/pipermail/enseignement/attachments/20140704/d7913901/attachment.htm>


Plus d'informations sur la liste de diffusion enseignement