/*************************************************************************************************************************************/
/* */
/* G E N E R A T I O N D ' U N E C O U R B E F R A C T A L E B I D I M E N S I O N N E L L E */
/* S O M M E T P A R S O M M E T ( N O N J O I N T S E N T R E - E U X ) : */
/* */
/* */
/* Author of '$xrc/Cfract_2D.01$K' : */
/* */
/* Jean-Francois COLONNA (LACTAMME, 1996??????????). */
/* */
/*************************************************************************************************************************************/
/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/* */
/* I N T E R F A C E ' listG ' : */
/* */
/* */
/* :Debut_listG: */
/* :Fin_listG: */
/* */
/*************************************************************************************************************************************/
/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/* */
/* D I R E C T I V E S S P E C I F I Q U E S D E C O M P I L A T I O N : */
/* */
/*************************************************************************************************************************************/
/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/* */
/* F I C H I E R S D ' I N C L U D E S : */
/* */
/*************************************************************************************************************************************/
#include INCLUDES_BASE
/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/* */
/* P A R A M E T R E S : */
/* */
/*************************************************************************************************************************************/
#define VISUALISER_EN_MODE_RECTANGULAIRE \
VRAI
#define VISUALISER_EN_MODE_GRAND_CARRE \
VRAI
/* Choix du format "rectangulaire"/"grand carre"/"petit carre" de visualisation lorsque */
/* le format d'image '$formatI' n'est pas carre (par exemple 'Pal'). */
#define VISUALISER_L_ARGUMENT \
VRAI \
/* Doit-on visualiser chaque point a l'aide de son argument ('VRAI') ou bien doit-on */ \
/* utiliser 'niveau_de_marquage_des_points' ('FAUX') ? */
#define NIVEAU_DE_MARQUAGE_DES_POINTS \
BLANC \
/* Niveau de marquage des points si 'IL_NE_FAUT_PAS(visualiser_l_argument)'. */
#define RAPPORT_DE_REDUCTION \
FTROIS \
/* Facteur de reduction initialise pour la courbe de von Koch ('v $xtc/VonKoch.01$c'). */
#define FACTEUR_DU_SEUIL_D_ARRET \
FU \
/* Facteur du seuil d'arret de la recursivite. */
#define XG \
FZERO
#define YG \
FDU
/* Definition de l'extremite "Gauche" de la courbe. */
#define XD \
FU
#define YD \
FDU
/* Definition de l'extremite "Droite" de la courbe. */
#define X_ECHELLE \
FU
#define Y_ECHELLE \
FU
/* Echelle du plan Complexe. */
#define X_TRANSLATION \
FZERO
#define Y_TRANSLATION \
FZERO
/* Translation du plan Complexe. */
#define CONSTRUIRE_00 \
VRAI
#define ANGLE_00 \
GRO0(FRA3(PI))
#define CONSTRUIRE_01 \
VRAI
#define ANGLE_01 \
GRO1(FRA3(PI))
#define CONSTRUIRE_02 \
VRAI
#define ANGLE_02 \
GRO4(FRA3(PI))
#define CONSTRUIRE_03 \
VRAI
#define ANGLE_03 \
GRO1(FRA3(PI))
#define CONSTRUIRE_04 \
FAUX
#define ANGLE_04 \
FZERO
#define CONSTRUIRE_05 \
FAUX
#define ANGLE_05 \
FZERO
#define CONSTRUIRE_06 \
FAUX
#define ANGLE_06 \
FZERO
#define CONSTRUIRE_07 \
FAUX
#define ANGLE_07 \
FZERO
#define CONSTRUIRE_08 \
FAUX
#define ANGLE_08 \
FZERO
#define CONSTRUIRE_09 \
FAUX
#define ANGLE_09 \
FZERO
#define CONSTRUIRE_10 \
FAUX
#define ANGLE_10 \
FZERO
#define CONSTRUIRE_11 \
FAUX
#define ANGLE_11 \
FZERO
#define CONSTRUIRE_12 \
FAUX
#define ANGLE_12 \
FZERO
#define CONSTRUIRE_13 \
FAUX
#define ANGLE_13 \
FZERO
#define CONSTRUIRE_14 \
FAUX
#define ANGLE_14 \
FZERO
#define CONSTRUIRE_15 \
FAUX
#define ANGLE_15 \
FZERO
/* Definition des angles de rotation initialises pour la courbe de von Koch (voir a ce */
/* propos 'v $xtc/VonKoch.01$c' et les programmes du type 'v $xtc/FracCurve.01$c'). On */
/* verra aussi avec interet 'v $xtc/FracCurve.11$c' qui tire au sort ses parametres, puis */
/* les edite. A titre d'exemple, la courbe : */
/* */
/* */
/* 2 ------- 3 */
/* */
/* | | */
/* | | */
/* | | */
/* */
/* 0 ------- 1 4 7 ------ 9 */
/* */
/* | | */
/* | | */
/* | | */
/* */
/* 5 ------- 6 */
/* */
/* */
/* s'obtient avec les parametres : */
/* */
/* c00=VRAI a00=0 */
/* c01=VRAI a01=+$pis2 */
/* c02=VRAI a02=-$pis2 */
/* c03=VRAI a03=-$pis2 */
/* c04=VRAI a04=0 */
/* c05=VRAI a05=+$pis2 */
/* c06=VRAI a06=+$pis2 */
/* c07=VRAI a07=-$pis2 */
/* rapport=4 */
/* */
/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/* */
/* M A C R O S U T I L E S : */
/* */
/*************************************************************************************************************************************/
#define ROTATION_ET_CONSTRUCTION(construire,angle) \
Bblock \
Test(IL_FAUT(construire)) \
Bblock \
Cegal(zG_reduit,zD_reduit); \
/* Initialisation du nombre "Gauche" avec le nombre "Droite". */ \
Crotation(z_difference_reduite,z_difference_reduite,angle); \
/* Rotation et homothetie du generateur. */ \
Csomme(zD_reduit,zG_reduit,z_difference_reduite); \
/* Initialisation du nombre "Droite" avec le nombre "Gauche" translate. */ \
CALS(construction_de_la_courbe_fractale(ADRESSE(zG_reduit),ADRESSE(zD_reduit))); \
/* Et enfin, construction recursive... */ \
Eblock \
ATes \
Bblock \
Eblock \
ETes \
Eblock \
/* Construction recursive de la courbe fractale... */
#define NIVEAU_DES_POINTS(point) \
COND(IL_FAUT(visualiser_l_argument) \
,GENP(SCAL(Cargument_2PI(point) \
,CERCLE_TRIGONOMETRIQUE \
,BLANC \
) \
) \
,niveau_de_marquage_des_points \
) \
/* Choix du niveau de marquage d'un point. */
/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/* */
/* D E F I N I T I O N D E L A C O U R B E F R A C T A L E B I D I M E N S I O N N E L L E : */
/* */
/*************************************************************************************************************************************/
DEFV(Local,DEFV(Logical,INIT(visualiser_l_argument,VISUALISER_L_ARGUMENT)));
/* Doit-on visualiser chaque point a l'aide de son argument ('VRAI') ou bien doit-on */
/* utiliser 'niveau_de_marquage_des_points' ('FAUX') ? */
DEFV(Local,DEFV(genere_p,INIT(niveau_de_marquage_des_points,NIVEAU_DE_MARQUAGE_DES_POINTS)));
/* Niveau de marquage des points si 'IL_NE_FAUT_PAS(visualiser_l_argument)'. */
DEFV(Local,DEFV(Float,INIT(rapport_de_reduction,RAPPORT_DE_REDUCTION)));
/* Facteur de reduction initialise pour la courbe de von Koch. */
DEFV(Local,DEFV(Float,INIT(facteur_du_seuil_d_arret,FACTEUR_DU_SEUIL_D_ARRET)));
/* Seuil d'arret de la recursivite. */
DEFV(coeffF_2D,echelle);
/* Echelle du plan Complexe. */
DEFV(deltaF_2D,translation);
/* Translation du plan Complexe. */
DEFV(Local,DEFV(Logical,INIT(construire_00,CONSTRUIRE_00)));
DEFV(Local,DEFV(Float,INIT(angle_00,ANGLE_00)));
DEFV(Local,DEFV(Logical,INIT(construire_01,CONSTRUIRE_01)));
DEFV(Local,DEFV(Float,INIT(angle_01,ANGLE_01)));
DEFV(Local,DEFV(Logical,INIT(construire_02,CONSTRUIRE_02)));
DEFV(Local,DEFV(Float,INIT(angle_02,ANGLE_02)));
DEFV(Local,DEFV(Logical,INIT(construire_03,CONSTRUIRE_03)));
DEFV(Local,DEFV(Float,INIT(angle_03,ANGLE_03)));
DEFV(Local,DEFV(Logical,INIT(construire_04,CONSTRUIRE_04)));
DEFV(Local,DEFV(Float,INIT(angle_04,ANGLE_04)));
DEFV(Local,DEFV(Logical,INIT(construire_05,CONSTRUIRE_05)));
DEFV(Local,DEFV(Float,INIT(angle_05,ANGLE_05)));
DEFV(Local,DEFV(Logical,INIT(construire_06,CONSTRUIRE_06)));
DEFV(Local,DEFV(Float,INIT(angle_06,ANGLE_06)));
DEFV(Local,DEFV(Logical,INIT(construire_07,CONSTRUIRE_07)));
DEFV(Local,DEFV(Float,INIT(angle_07,ANGLE_07)));
DEFV(Local,DEFV(Logical,INIT(construire_08,CONSTRUIRE_08)));
DEFV(Local,DEFV(Float,INIT(angle_08,ANGLE_08)));
DEFV(Local,DEFV(Logical,INIT(construire_09,CONSTRUIRE_09)));
DEFV(Local,DEFV(Float,INIT(angle_09,ANGLE_09)));
DEFV(Local,DEFV(Logical,INIT(construire_10,CONSTRUIRE_10)));
DEFV(Local,DEFV(Float,INIT(angle_10,ANGLE_10)));
DEFV(Local,DEFV(Logical,INIT(construire_11,CONSTRUIRE_11)));
DEFV(Local,DEFV(Float,INIT(angle_11,ANGLE_11)));
DEFV(Local,DEFV(Logical,INIT(construire_12,CONSTRUIRE_12)));
DEFV(Local,DEFV(Float,INIT(angle_12,ANGLE_12)));
DEFV(Local,DEFV(Logical,INIT(construire_13,CONSTRUIRE_13)));
DEFV(Local,DEFV(Float,INIT(angle_13,ANGLE_13)));
DEFV(Local,DEFV(Logical,INIT(construire_14,CONSTRUIRE_14)));
DEFV(Local,DEFV(Float,INIT(angle_14,ANGLE_14)));
DEFV(Local,DEFV(Logical,INIT(construire_15,CONSTRUIRE_15)));
DEFV(Local,DEFV(Float,INIT(angle_15,ANGLE_15)));
/* Definition des angles de rotation initialises pour la courbe de von Koch. */
/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/* */
/* P R O C E D U R E R E C U R S I V E D E */
/* G E N E R A T I O N D ' U N E C O U R B E F R A C T A L E B I D I M E N S I O N N E L L E */
/* S O M M E T P A R S O M M E T ( N O N J O I N T S E N T R E - E U X ) : */
/* */
/*************************************************************************************************************************************/
BFonctionI
DEFV(Local,DEFV(FonctionI,construction_de_la_courbe_fractale(ARGUMENT_POINTERs(AzG),ARGUMENT_POINTERs(AzD))))
DEFV(Argument,DEFV(complexe,POINTERs(AzG)));
DEFV(Argument,DEFV(complexe,POINTERs(AzD)));
/* Nombres "Gauche" et "Droite" courants. */
/*-----------------------------------------------------------------------------------------------------------------------------------*/
Bblock
DEFV(complexe,zG);
DEFV(complexe,zD);
/* Nombres "Gauche" et "Droite" courants. */
DEFV(complexe,z_difference);
/* Difference entre les nombres "Gauche" et "Droite" courants. */
INIT_ERROR;
/*..............................................................................................................................*/
Cegal(zG,INDIRECT(AzG));
Cegal(zD,INDIRECT(AzD));
/* Recuperation des nombres "Gauche" et "Droite" courants. */
Cdifference(z_difference,zD,zG);
/* Calcul de la difference entre les nombres "Gauche" et "Droite" courants. */
Test(IFLT(Cmodule(z_difference),MUL2(facteur_du_seuil_d_arret,MIN2(_____lNORMALISE_OX(pasX),_____lNORMALISE_OY(pasY)))))
/* On note le 20200806175355 que le test d'arret par defaut correspond au cas ou la */
/* taille du segment courant est de l'ordre de l'inter-point... */
Bblock
DEFV(complexe,zG_translate);
DEFV(complexe,zD_translate);
/* Nombres "Gauche" et "Droite" courants translates. */
Cinitialisation(zG_translate
,AXPB(ASD1(echelle,cx),Reelle(zG),ASD1(translation,dx))
,AXPB(ASD1(echelle,cy),Imaginaire(zG),ASD1(translation,dy))
);
Cinitialisation(zD_translate
,AXPB(ASD1(echelle,cx),Reelle(zD),ASD1(translation,dx))
,AXPB(ASD1(echelle,cy),Imaginaire(zD),ASD1(translation,dy))
);
/* Translation et mise a l'echelle du plan Complexe... */
store_point_valide(NIVEAU_DES_POINTS(zG_translate)
,ImageR
,SUPER_cDENORMALISE_OX(Reelle(zG))
,SUPER_cDENORMALISE_OY(Imaginaire(zG))
,FVARIABLE
);
store_point_valide(NIVEAU_DES_POINTS(zD_translate)
,ImageR
,SUPER_cDENORMALISE_OX(Reelle(zD))
,SUPER_cDENORMALISE_OY(Imaginaire(zD))
,FVARIABLE
);
/* Marquage des nombres "Gauche" et "Droite" courants lorsque le seuil est atteint, */
/* la courbe etant donc materialisee uniquement par ses sommets qui ne sont pas joints, */
/* mais ce qui ne soiut pas par defaut (seuil=1)... */
/* */
/* ATTENTION, ce n'est pas une erreur de trouver (par exemple) : */
/* */
/* NIVEAU_DES_POINTS(zG_translate) */
/* */
/* et : */
/* */
/* Reelle(zG) */
/* Imaginaire(zG) */
/* */
/* en effet, ainsi, cela permet de modifier l'origine du plan Complexe pour fixer le */
/* "centre" du coloriage si 'IL_FAUT(visualiser_l_argument)' sans pour cela deplacer */
/* la courbe generee... */
Eblock
ATes
Bblock
DEFV(complexe,z_difference_reduite);
/* Afin de reduire la difference courante suivant le facteur et l'angle courants... */
DEFV(complexe,zG_reduit);
DEFV(complexe,zD_reduit);
/* Nouveaux nombres "Gauche" et "Droite" apres reduction... */
Cegal(zD_reduit,zG);
/* Initialisation du nombre "Droite" reduit avec le nombre "Gauche" courant. */
Chomothetie(z_difference_reduite,z_difference,INVE(rapport_de_reduction));
/* Reduction de la difference courante suivant le facteur courant. */
ROTATION_ET_CONSTRUCTION(construire_00,angle_00);
ROTATION_ET_CONSTRUCTION(construire_01,angle_01);
ROTATION_ET_CONSTRUCTION(construire_02,angle_02);
ROTATION_ET_CONSTRUCTION(construire_03,angle_03);
ROTATION_ET_CONSTRUCTION(construire_04,angle_04);
ROTATION_ET_CONSTRUCTION(construire_05,angle_05);
ROTATION_ET_CONSTRUCTION(construire_06,angle_06);
ROTATION_ET_CONSTRUCTION(construire_07,angle_07);
ROTATION_ET_CONSTRUCTION(construire_08,angle_08);
ROTATION_ET_CONSTRUCTION(construire_09,angle_09);
ROTATION_ET_CONSTRUCTION(construire_10,angle_10);
ROTATION_ET_CONSTRUCTION(construire_11,angle_11);
ROTATION_ET_CONSTRUCTION(construire_12,angle_12);
ROTATION_ET_CONSTRUCTION(construire_13,angle_13);
ROTATION_ET_CONSTRUCTION(construire_14,angle_14);
ROTATION_ET_CONSTRUCTION(construire_15,angle_15);
Eblock
ETes
RETU_ERROR;
Eblock
EFonctionI
/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/* */
/* G E N E R A T I O N D ' U N E C O U R B E F R A C T A L E B I D I M E N S I O N N E L L E */
/* S O M M E T P A R S O M M E T ( N O N J O I N T S E N T R E - E U X ) : */
/* */
/*************************************************************************************************************************************/
BCommande(nombre_d_arguments,arguments)
/*-----------------------------------------------------------------------------------------------------------------------------------*/
Bblock
DEFV(CHAR,INIC(POINTERc(nom_imageR),NOM_PIPE));
DEFV(Float,INIT(xG,XG));
DEFV(Float,INIT(yG,YG));
/* Definition de l'extremite "Gauche" de la courbe. */
DEFV(Float,INIT(xD,XD));
DEFV(Float,INIT(yD,YD));
/* Definition de l'extremite "Droite" de la courbe. */
DEFV(complexe,zG);
DEFV(complexe,zD);
/* Nombres "Gauche" et "Droite" de depart... */
/*..............................................................................................................................*/
#include xci/coordonne.04.I"
/* Ceci a ete introduit le 20051218184043, ainsi que les 'PROCESS_ARGUMENT_?(...)' qui */
/* suivent... */
INITIALISATION_ACCROISSEMENT_2D(translation,X_TRANSLATION,Y_TRANSLATION);
/* Initialisation de la translation du plan Complexe. */
INITIALISATION_COEFFICIENT_2D(echelle,X_ECHELLE,Y_ECHELLE);
/* Initialisation de l'echelle du plan Complexe. */
GET_ARGUMENTSi(nombre_d_arguments
,BLOC(GET_ARGUMENT_C("imageR=""R=",nom_imageR);
GET_ARGUMENT_L("argument=",visualiser_l_argument);
GET_ARGUMENT_P("niveau=""n=",niveau_de_marquage_des_points);
GET_ARGUMENT_F("rapport=""r=",rapport_de_reduction);
GET_ARGUMENT_F("seuil=""s=",facteur_du_seuil_d_arret);
GET_ARGUMENT_F("XG=""xG=",xG);
GET_ARGUMENT_F("YG=""yG=",yG);
GET_ARGUMENT_F("XD=""xD=",xD);
GET_ARGUMENT_F("YD=""yD=",yD);
/* On notera le 20200806172508 que faire : */
/* */
/* xG=0 */
/* */
/* n */
/* xD=3 avec n E [0,1,2,...] */
/* */
/* montre la courbe entiere (n=0), puis un zoom "auto-similaire" de rapport 3 (n=1), un zoom */
/* "auto-similaire" de rapport 9 (n=2), un zoom "auto-similaire" de rapport 27 (n=3),... */
/* */
/* Le 20200808102255 les majuscules ont ete introduites pour {x,y}... */
GET_ARGUMENT_F("Tx=",ASD1(translation,dx));
GET_ARGUMENT_F("Ty=",ASD1(translation,dy));
GET_ARGUMENT_F("Ex=",ASD1(echelle,cx));
GET_ARGUMENT_F("Ey=",ASD1(echelle,cy));
GET_ARGUMENT_L("c00=",construire_00);
GET_ARGUMENT_F("a00=",angle_00);
GET_ARGUMENT_L("c01=",construire_01);
GET_ARGUMENT_F("a01=",angle_01);
GET_ARGUMENT_L("c02=",construire_02);
GET_ARGUMENT_F("a02=",angle_02);
GET_ARGUMENT_L("c03=",construire_03);
GET_ARGUMENT_F("a03=",angle_03);
GET_ARGUMENT_L("c04=",construire_04);
GET_ARGUMENT_F("a04=",angle_04);
GET_ARGUMENT_L("c05=",construire_05);
GET_ARGUMENT_F("a05=",angle_05);
GET_ARGUMENT_L("c06=",construire_06);
GET_ARGUMENT_F("a06=",angle_06);
GET_ARGUMENT_L("c07=",construire_07);
GET_ARGUMENT_F("a07=",angle_07);
GET_ARGUMENT_L("c08=",construire_08);
GET_ARGUMENT_F("a08=",angle_08);
GET_ARGUMENT_L("c09=",construire_09);
GET_ARGUMENT_F("a09=",angle_09);
GET_ARGUMENT_L("c10=",construire_10);
GET_ARGUMENT_F("a10=",angle_10);
GET_ARGUMENT_L("c11=",construire_11);
GET_ARGUMENT_F("a11=",angle_11);
GET_ARGUMENT_L("c12=",construire_12);
GET_ARGUMENT_F("a12=",angle_12);
GET_ARGUMENT_L("c13=",construire_13);
GET_ARGUMENT_F("a13=",angle_13);
GET_ARGUMENT_L("c14=",construire_14);
GET_ARGUMENT_F("a14=",angle_14);
GET_ARGUMENT_L("c15=",construire_15);
GET_ARGUMENT_F("a15=",angle_15);
)
);
Test(IFGT(rapport_de_reduction,FU))
Bblock
Eblock
ATes
Bblock
PRINT_ERREUR("le rapport de reduction doit etre strictement superieur a 1");
PRINT_ERREUR("la valeur par defaut est donc forcee");
EGAL(rapport_de_reduction,RAPPORT_DE_REDUCTION);
CAL1(Prer1("elle vaut : %.^^^\n",rapport_de_reduction));
/* Le 20060105155956, le format "16g" est passe a "^^g" pour plus de souplesse... */
/* */
/* Le 20091123123401, le format "^^g" est passe a "^^^" pour plus de souplesse... */
Eblock
ETes
CALi(Inoir(ImageR));
Cinitialisation(zG,xG,yG);
Cinitialisation(zD,xD,yD);
/* Initialisation des extremites de la courbe. */
CALS(construction_de_la_courbe_fractale(ADRESSE(zG),ADRESSE(zD)));
/* Construction de la courbe. */
CALi(Iupdate_image(nom_imageR,ImageR));
RETU_Commande;
Eblock
ECommande