_______________________________________________________________________________________________________________________________________
/*************************************************************************************************************************************/
/* */
/* F O N C T I O N S D E G E N E R A T I O N S A L E A T O I R E S : */
/* */
/* */
/* Definition : */
/* */
/* Ce fichier contient toutes les fonctions */
/* de base de generation de champs aleatoires. */
/* */
/* */
/* Author of '$xiii/aleat.1$FON' : */
/* */
/* Jean-Francois COLONNA (LACTAMME, 19870000000000). */
/* */
/*************************************************************************************************************************************/
/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/* */
/* C H A M P C O M P L E T E M E N T A L E A T O I R E E N N I V E A U X */
/* P E R M E T T A N T , P A R E X E M P L E , D E T E S T E R V I S U E L L E M E N T */
/* L A Q U A L I T E D U G E N E R A T E U R A L E A T O I R E : */
/* */
/* */
/* ..@.@@@@@@@* ..@ @ . .@*@**@* @. @ @. @**@. .. * *** .*@* @. */
/* .@@.*. *.**. @. @**... ..@ * .** * @.@ *@*@ @*@* .@**** * */
/* ** * * . **@ **.* **..* . *.**.@@*..*@@.. @.@*.* ..*.. .@. @*@ */
/* @ ...@ @ *.@@*@.** .. . . ** ..@.@.**@*@ @**@ . @ @@@@ @. */
/* @ @*.** @*@@.@@ ** . .**..* @@**@@@.@. ..@ @*....@.@@*.@ .*.* */
/* @@ .* @...*@@* @* ...@@@* ...@**@ @* *@@ ..@@...****...*.@@ *. */
/* ..@@. . *@@*@. *@@ . @@ *@@* .**.@.@@ .*. .@ . ** .@@@.**@ */
/* . *..@@ **@.@@*..@@.*.@ ** * @. * *.@@*@..@ @ . *@@.@@ **@ */
/* *.@@.@@ . * @..@* . .@@ *@***@ .. .@..@@**. .@ *@..**. */
/* . **. @* .@**.. @@.@.*. @ .@ ..@@@. @*. **.. *. @ * *@..@.*. */
/* @@.. .*@*.@*@ **@@ *@@@...@ .* * *..*@..@@*@...*@@. @ .. @**. */
/* * * **.**@@ @* @.. .@.@**..@ @.. * @ *@@@@**@ .* ** @* *@ */
/* * @ .@@ **@@* ..**. @ ** @ .@*..@*@. .* ..@*... **@.*.. ** *.@* */
/* *.*..@. .*@.@@ *.@..* *@@@ * .***.**..@ @*.@.. .. @ @*.@ @ @* */
/* @@@ ..*@.@@ @. .@.** . @*@*.@@ .* .@@.*.*@ @ @.*.. ..@**@.*@ */
/* @@@@@*@ . *@@*.@@ *@* .* .@**@* ***. @@@*.***.** @.*.@ .*@@* */
/* @ . . .. *@*.*@ . * .@@@@*@. @. .* . *@ *....*@.**.@@* . @. */
/* . . *@@@** .* .@@@@.....** @*.@.* @* . . .. @ ****. @.@@@**.@. */
/* . . @ * .@* @. .*@ @ .... @ . @ @@@.* @ @ @ @* @.@@**. .** */
/* @. .* @...*. **@*@*.@ * * @. **. *.*@.@.. * @ *@@ ..** .@*@* */
/* ***@***@*@.**.* .**@ .@*@*.@*. ...@.* @@.. ..* @@@@. @@@@*. */
/* @ * @.*@ * @* * *@ @* *.. * @*@ @ * .....*@. .@@ *@*@*.**@ */
/* . .**.@@ @ . @ @* .@.* @** .@***@* *@ . @@**@* @**.... ....@* */
/* @....@. *. .@...@..*.** @ @.** . @ .* *.@** *.@ *. @.@* *.@ */
/* .* . @*.*@* .. @*@...@@*.* * ***. * @@ @.@.. * *@*.@*.***. */
/* @@*.@@....@*.*@.**@..@.@* ** @*..** *@. @*...@@. @@@. .**...@ */
/* @**@* . . * **@.. @.. * @*@**@*. . @.. *@@@.*@ .**@*.*@ **** */
/* ..*@@@.@ @ . *..** *. @@*.. ..*.@ * @ @@**.@.* **@@*@@@ @* */
/* ... @**...@.* **@.* @.@ .@.*. *@ *@ .@.. *****.@. .@.@ @@* */
/* *.**@*@ **.*@* ***@@. *.*.@ *. @ .@**.*@.* @*@. ** @@* @*.@@@@ */
/* @@ ** @..*@ @@. @.@*.****@ ..@*@.*. * @ @.. @ .**@@*. @*@ .. @ */
/* ** ***.**@@.*** ***@ @. @ * @@@.* *.@* @ @. * *..@* @. */
/* */
/* */
/*************************************************************************************************************************************/
BFonctionP
DEFV(Common,DEFV(Float,SINT(Irandom_niveaux_____maximum_ouvert,FLOT__BLANC)));
DEFV(Common,DEFV(Float,SINT(Irandom_niveaux_____maximum_ferme,FLOT__BLANC)));
/* Introduit le 20190124112346 pour permettre de garantir, si besoin est, l'equirepartition */
/* des niveaux y compris aux deux extremites 'NOIR' et 'BLANC' d'un histogramme (on prendra */
/* alors la valeur 'FLOT__BLANC+1'...). */
/* */
/* Au passage, ce phenomene d'equirepartition des niveaux dans l'histogramme, sauf aux */
/* deux extremites 'NOIR' et 'BLANC', vient du fait que chaque niveau est atteint a la */
/* fois par la droite (par defaut) et par la gauche (par exces) a cause de la programmation */
/* 'v $ximf/aleatoires$FON RETU.ARRI.rdn..' et evidemment cet acces a la fois par la droite */
/* et par la gauche n'est pas possible pour le 'NOIR' (accessible uniquement par defaut) */
/* et pour le 'BLANC' (accessible uniquement par exces) ainsi que le montre la figure */
/* suivante : */
/* */
/* */
/* HISTOGRAMME : NOIR (...) NIVEAU (...) BLANC */
/* QUELCONQUE */
/* | | */
/* | | | */
/* | | | */
/* |<- ->|<- ->| */
/* */
/* (defaut seul) (exces+defaut) (exces seul) */
/* */
DEFV(Common,DEFV(FonctionP,POINTERp(Irandom_niveaux(imageR,graine,borne_inferieure,borne_superieure))))
DEFV(Argument,DEFV(image,imageR));
/* Image Resultat, telle que : imageR[X][Y]=rdn((X,Y),graine,(inf,sup)). */
DEFV(Argument,DEFV(Int,graine));
/* Graine arbitraire dont depend la generation. */
DEFV(Argument,DEFV(Float,borne_inferieure));
/* Borne inferieure du generateur ; 'NOIR' est une bonne valeur, */
DEFV(Argument,DEFV(Float,borne_superieure));
/* Borne superieure du generateur ; 'BLANC' est une bonne valeur. */
/*-----------------------------------------------------------------------------------------------------------------------------------*/
Bblock
DEFV(pointI_2D,point_courant);
/* Point (entier) courant. */
/*..............................................................................................................................*/
INITIALISATION_POINT_2D(point_courant,Xmin,Ymin);
CALS(rdnaI2D(ADRESSE(point_courant)
,UNDEF
,RDN_INIT
,gTRNP(borne_inferieure,Irandom_niveaux_____maximum_ouvert,Irandom_niveaux_____maximum_ferme)
,gTRNP(borne_superieure,Irandom_niveaux_____maximum_ouvert,Irandom_niveaux_____maximum_ferme)
)
);
/* Initialisation du generateur aleatoire avec des bornes dans [NOIR,BLANC]. */
begin_image
Bblock
INITIALISATION_POINT_2D(point_courant,X,Y);
store_point(rdnaI2D(ADRESSE(point_courant),graine,RDN_GENERE,FLOT__ARGUMENT_ABSENT,FLOT__ARGUMENT_ABSENT)
,imageR
,X,Y
,FVARIABLE
);
/* Generation d'une valeur aleatoire fonction du point courant {X,Y}, */
/* de la graine argument comprise entre les bornes inferieure et */
/* superieure. */
Eblock
end_image
RETI(imageR);
Eblock
EFonctionP
_______________________________________________________________________________________________________________________________________
_______________________________________________________________________________________________________________________________________
/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/* */
/* C H A M P C O M P L E T E M E N T A L E A T O I R E E N N I V E A U X */
/* P E R M E T T A N T , P A R E X E M P L E , D E T E S T E R V I S U E L L E M E N T */
/* L A Q U A L I T E D U G E N E R A T E U R A L E A T O I R E : */
/* */
/*************************************************************************************************************************************/
BFonctionF
DEFV(Common,DEFV(FonctionF,POINTERF(IFrandom_niveaux(imageR,graine,borne_inferieure,borne_superieure))))
DEFV(Argument,DEFV(imageF,imageR));
/* Image Resultat, telle que : imageR[X][Y]=rdn((X,Y),graine,(inf,sup)). */
DEFV(Argument,DEFV(Int,graine));
/* Graine arbitraire dont depend la generation. */
DEFV(Argument,DEFV(Float,borne_inferieure));
/* Borne inferieure du generateur ; 'NOIR' est une bonne valeur, */
DEFV(Argument,DEFV(Float,borne_superieure));
/* Borne superieure du generateur ; 'BLANC' est une bonne valeur. */
/*-----------------------------------------------------------------------------------------------------------------------------------*/
Bblock
DEFV(pointI_2D,point_courant);
/* Point (entier) courant. */
/*..............................................................................................................................*/
INITIALISATION_POINT_2D(point_courant,Xmin,Ymin);
CALS(rdnI2D(ADRESSE(point_courant)
,UNDEF
,RDN_INIT
,borne_inferieure
,borne_superieure
)
);
/* Initialisation du generateur aleatoire avec des bornes dans [NOIR,BLANC]. */
begin_image
Bblock
INITIALISATION_POINT_2D(point_courant,X,Y);
storeF_point(rdnI2D(ADRESSE(point_courant),graine,RDN_GENERE,FLOT__ARGUMENT_ABSENT,FLOT__ARGUMENT_ABSENT)
,imageR
,X,Y
);
/* Generation d'une valeur aleatoire fonction du point courant {X,Y}, */
/* de la graine argument comprise entre les bornes inferieure et */
/* superieure. */
Eblock
end_image
RETIF(imageR);
Eblock
EFonctionF
_______________________________________________________________________________________________________________________________________
_______________________________________________________________________________________________________________________________________
/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/* */
/* C H A M P C O M P L E T E M E N T A L E A T O I R E E N N I V E A U X */
/* D O N T L A P E R I O D I C I T E E S T P A R A M E T R A B L E : */
/* */
/*************************************************************************************************************************************/
BFonctionP
DEFV(Common,DEFV(FonctionP,POINTERp(Irandom_niveaux_a_periodicite_parametrable(imageR))))
DEFV(Argument,DEFV(image,imageR));
/* Image Resultat, telle que : imageR[X][Y]=rdn. */
/*-----------------------------------------------------------------------------------------------------------------------------------*/
Bblock
/*..............................................................................................................................*/
begin_image
Bblock
DEFV(Float,INIT(valeur_aleatoire_courante,rdn_iteratif_cercle()));
store_point(__DENORMALISE_NIVEAU(valeur_aleatoire_courante)
,imageR
,X,Y
,FVARIABLE
);
/* Generation d'une valeur aleatoire. On notera qu'il est interdit d'ecrire directement : */
/* */
/* __DENORMALISE_NIVEAU(rdn_iteratif_cercle()) */
/* */
/* parce que cela provoque plusieurs appels a 'rdn_iteratif_cercle(...)' via 'TRNF(...)'. */
Eblock
end_image
RETI(imageR);
Eblock
EFonctionP
_______________________________________________________________________________________________________________________________________
_______________________________________________________________________________________________________________________________________
/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/* */
/* C H A M P C O M P L E T E M E N T A L E A T O I R E E N N I V E A U X */
/* D O N T L A P E R I O D I C I T E E S T P A R A M E T R A B L E : */
/* */
/*************************************************************************************************************************************/
BFonctionF
DEFV(Common,DEFV(FonctionF,POINTERF(IFrandom_niveaux_a_periodicite_parametrable(imageR))))
DEFV(Argument,DEFV(imageF,imageR));
/* Image Resultat, telle que : imageR[X][Y]=rdn. */
/*-----------------------------------------------------------------------------------------------------------------------------------*/
Bblock
/*..............................................................................................................................*/
begin_image
Bblock
DEFV(Float,INIT(valeur_aleatoire_courante,rdn_iteratif_cercle()));
/* Par symetrie avec 'Irandom_niveaux_a_periodicite_parametrable(...)'. */
storeF_point(valeur_aleatoire_courante
,imageR
,X,Y
);
/* Generation d'une valeur aleatoire. */
Eblock
end_image
RETIF(imageR);
Eblock
EFonctionF
_______________________________________________________________________________________________________________________________________
_______________________________________________________________________________________________________________________________________
/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/* */
/* C H A M P C O M P L E T E M E N T A L E A T O I R E E N P O S I T I O N : */
/* */
/* */
/* @@@@@ @@@@@@@@@@@@@@@@@ @@ @@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@ */
/* @@@@@ @@@@ @@@@@@ @ @@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@ */
/* @@@@@@@@@@ @@@ @@@@@@@@@@@@ @@@@@@ @@@ @@@@@@@@@@@@ @@@@@@ @@@ @ */
/* @@@@@@ @@@@@@ @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ */
/* @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@ @@@@@@ */
/* @@@@@@@@@@@@ @@@@@@@@ @@@@@@@@@@@@@@@@@@@@@ @@@@@@@ @@@@@@@@@@@ */
/* @@@@@ @@@ @@@@@@@@@ @@@@@@@@@@@@@ @@@@@@@@@@ @@@@@@@@@@@@@@@@ @@ */
/* @@@@@ @@@@@ @ @@@@@ @@@@@@@ @@@@@@@@@ @@@@@ @@@@@ @@@@@@@@@@ @@ */
/* @@@ @@@@@@@@ @@@ @@@@@@@@@@ @@@@ @@@@@@@@@@@ @@@@@@ @@@@@@ @@@@ */
/* @@@@@@@@@@@@@ @@@@ @@ @@@@ @ @@@@ @@@@@ @@@@ @@ @@ @@@@ @@@@@@@@ */
/* @@@@@@@@@@ @@@@ @@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@ @@@@ @@@@@ @@ */
/* @@@@@@@@@@@@@@@@@@ @@@ @@@ @@ @@@@@@@@@@@ @@@@@@@ @@ @@@@@@@@@@@ */
/* @@@@ @ @@@@@@@@ @@@@@@@@@ @@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@ @@ */
/* @@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@ @@@@@@@@@@ @@@@@ */
/* @@@@@@@@@@@@@@@@ @@@@@@@@@@ @@@@ @@@@@@ @@@@ @@@@@@@@@@@@@@@@@ */
/* @@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@ @@@ @@@@@@@@@@@@@@@ */
/* @@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@ @@@@ */
/* @@ @ @@ @@@@@@@@@@ @@@ @@@@@@@@@@@@@@@@@@@ @@@@ @@@@@@@@@@@@@@ */
/* @ @@@@@@@@@@@ @@@@@@ @@@@@@@ @@@@@@ @@@@@ @@ @@@@@@@@@@@ @@@@@@@ */
/* @@@ @@@@ @@@@@@@ @@@@@@@@@ @@@ @@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@ */
/* @@@@ @@@@@ @@@@@@@ @@@@ @@@ @@@@@@@@@@@@@ @@ @@@@@@@@@@@@@@@ @@@ */
/* @@@@@@@ @@@@@@@@@ @@@@ @@@@@@ @@@@@@@ @@@@@@@@@@@ @ @@@@@@@ @@@ */
/* @@@@@@@@@@@@@@@@@@ @@@@@@@@@ @@@@@@@@@@@ @@ @@@ @@@@ @@@@@@ @@@@ */
/* @@@@@@@@@@@@@ @@@@@@ @@@@@@@@@@@@ @ @@ @@@ @@@@ @@@@@@@@@@@@@@ */
/* @@@@@@ @@@ @@ @@@@@@@@@@@@@@@@@@@@@ @@@ @@@@@@@ @@@@@@@@@@@@@@@@ */
/* @@@@@@@@@@@@@@@@@@ @@ @ @@@@@@@@@@@@@ @ @ @ @ @@@@@@@@@@@@@ @@ */
/* @@@@@@@@@ @@@@@ @ @@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@ @@ @@@@@@@@@@ */
/* @@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@ @@ @ @@@@@@@@ @@@@@ */
/* @@@@@@@ @@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@ @@@@@@ @@@@@@@@ @@@ */
/* @@@@ @ @@@@ @@@@@@@@@@@@@ @@@@@@@@@@@@ @@@@ @@@@@@@@@@@@@@@@ @@ */
/* @@@@@ @ @@@@@@@@@@@@@@ @@@@@@@@@@ @ @@@@@@@@@@@@ @@@@ @@@@@@@@@@ */
/* @@@@@@@@@@ @@@@@@@@@@@@@@@@@ @@ @@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@ */
/* */
/* */
/*************************************************************************************************************************************/
BFonctionP
DEFV(Common,DEFV(Positive,SINT(Irandom_positions_____nombre_de_points_marques,UNDEF)));
/* Introduit le 20240828092008... */
DEFV(Common,DEFV(genere_p,SINT(Irandom_positions_____niveau_des_points_probables,NIVEAU_DES_POINTS_PROBABLES)));
/* Introduit le 20140807100850 pour 'v $xci/random.02$K Irandom_positions'... */
DEFV(Common,DEFV(FonctionP,POINTERp(Irandom_positions(imageR,graine,seuil_de_generation))))
DEFV(Argument,DEFV(image,imageR));
/* Image Resultat, telle que : imageR[X][Y]=un point {X,Y} si la probabilite est favorable. */
DEFV(Argument,DEFV(Int,graine));
/* Graine arbitraire dont depend la generation. */
DEFV(Argument,DEFV(Float,seuil_de_generation));
/* Definition du seuil de generation ; il s'agit en fait d'une probabilite */
/* definie dans [0,1]. La generation est donc conditionnee par : */
/* */
/* rdn(X,Y) <= seuil : on genere un point en {X,Y}, */
/* rdn(X,Y) > seuil : on laisse le point {X,Y} inchange. */
/* */
/*-----------------------------------------------------------------------------------------------------------------------------------*/
Bblock
DEFV(Float,INIT(borne_inferieure,PROBABILITE_NULLE));
/* Borne inferieure du generateur, */
DEFV(Float,INIT(borne_superieure,PROBABILITE_UNITE));
/* Borne superieure du generateur. */
DEFV(pointI_2D,point_courant);
/* Point (entier) courant. */
/*..............................................................................................................................*/
Test(NINCff(seuil_de_generation,borne_inferieure,borne_superieure))
Bblock
PRINT_ATTENTION("la probabilite de generation n'est pas dans le segment [0,1]");
Eblock
ATes
Bblock
Eblock
ETes
INITIALISATION_POINT_2D(point_courant,Xmin,Ymin);
CALS(rdnI2D(ADRESSE(point_courant),UNDEF,RDN_INIT,borne_inferieure,borne_superieure));
/* Initialisation du generateur aleatoire. */
CLIR(Irandom_positions_____nombre_de_points_marques);
/* Introduit le 20240828092008... */
begin_image
Bblock
INITIALISATION_POINT_2D(point_courant,X,Y);
Test(IFLE(rdnI2D(ADRESSE(point_courant),graine,RDN_GENERE,FLOT__ARGUMENT_ABSENT,FLOT__ARGUMENT_ABSENT)
,seuil_de_generation
)
)
Bblock
store_point(Irandom_positions_____niveau_des_points_probables,imageR,X,Y,FVARIABLE);
/* Generation du point courant {X,Y}, lorsque la probabilite est favorable... */
INCR(Irandom_positions_____nombre_de_points_marques,I);
/* Introduit le 20240828092008... */
Eblock
ATes
Bblock
Eblock
ETes
Eblock
end_image
RETI(imageR);
Eblock
EFonctionP
_______________________________________________________________________________________________________________________________________
_______________________________________________________________________________________________________________________________________
/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/* */
/* P E R M U T A T I O N A L E A T O I R E D E S P O I N T D ' U N E I M A G E : */
/* */
/*************************************************************************************************************************************/
BFonctionP
DEFV(Common,DEFV(Logical,SINT(Irandom_shuffling_____compatibilite_20160201,FAUX)));
/* Permet de generer des images suivant la methode anterieure au 20160201125046... */
DEFV(Common,DEFV(Int,SINT(Irandom_shuffling_____increment_1_coordonnee_X,NEUT(PasX))));
DEFV(Common,DEFV(Int,SINT(Irandom_shuffling_____increment_1_coordonnee_Y,NEUT(PasX))));
DEFV(Common,DEFV(Int,SINT(Irandom_shuffling_____increment_2_coordonnee_X,NEGA(PasX))));
DEFV(Common,DEFV(Int,SINT(Irandom_shuffling_____increment_2_coordonnee_Y,NEGA(PasX))));
/* Afin de parametrer la fonction 'rdnI2D(...)'. */
DEFV(Common,DEFV(Int,SINT(Irandom_shuffling_____nombre_maximal_de_collisions,ZERO)));
DEFV(Common,DEFV(Int,SINT(Irandom_shuffling_____limite_du_detecteur_de_collisions,CENT)));
/* Afin de gerer les collisions. Ce dispositif a ete introduit le 20160201102456 et donner */
/* une valeur "infinie" a 'nombre_maximal_de_collisions' autorise donc les collisions */
/* telles qu'elles etaient possibles avant cette date... */
DEFV(Common,DEFV(FonctionP,POINTERp(Irandom_shuffling(imageR,imageA,graine,seuil_de_generation))))
DEFV(Argument,DEFV(image,imageR));
/* Image Resultat, telle que : imageR[X][Y]=Permutation(imageA[X][Y]). */
DEFV(Argument,DEFV(image,imageA));
/* Image Argument. */
DEFV(Argument,DEFV(Int,graine));
/* Graine arbitraire dont depend la generation. */
DEFV(Argument,DEFV(Float,seuil_de_generation));
/* Definition du seuil de generation ; il s'agit en fait d'une probabilite */
/* definie dans [0,1]. La generation est donc conditionnee par : */
/* */
/* rdn(X,Y) <= seuil : on permute le point {X,Y} avec un point aleatoire, */
/* rdn(X,Y) > seuil : on laisse le point {X,Y} inchange. */
/* */
/*-----------------------------------------------------------------------------------------------------------------------------------*/
Bblock
DEFV(Float,INIT(borne_inferieure,PROBABILITE_NULLE));
/* Borne inferieure du generateur, */
DEFV(Float,INIT(borne_superieure,PROBABILITE_UNITE));
/* Borne superieure du generateur. */
DEFV(pointI_2D,point_courant);
/* Point (entier) courant. */
BDEFV(imageI,matrice_des_nombres_de_collisions);
/* Afin de pouvoir eviter, si besoin est, les "collisions"... */
/*..............................................................................................................................*/
Test(NINCff(seuil_de_generation,borne_inferieure,borne_superieure))
Bblock
PRINT_ATTENTION("la probabilite de generation n'est pas dans le segment [0,1]");
Eblock
ATes
Bblock
Eblock
ETes
INITIALISATION_POINT_2D(point_courant,Xmin,Ymin);
CALS(rdnI2D(ADRESSE(point_courant),UNDEF,RDN_INIT,borne_inferieure,borne_superieure));
/* Initialisation du generateur aleatoire. */
CALS(IIinitialisation(matrice_des_nombres_de_collisions,ZERO));
/* Initialement, aucune collision... */
begin_image
Bblock
DEFV(genere_p,INIT(niveau_du_point_courant,load_point(imageA,X,Y)));
INITIALISATION_POINT_2D(point_courant,X,Y);
Test(IFLE(rdnI2D(ADRESSE(point_courant),graine,RDN_GENERE,FLOT__ARGUMENT_ABSENT,FLOT__ARGUMENT_ABSENT)
,seuil_de_generation
)
)
Bblock
DEFV(Logical,INIT(iterer_le_shuffling,VRAI));
DEFV(Logical,INIT(nombre_courant_d_iterations_lors_des_collisions,ZERO));
DEFV(Int,INIT(facteur_des_increments_des_coordonnees
,COND(IL_FAUT(Irandom_shuffling_____compatibilite_20160201),UN,UN)
)
);
/* La reference a la "compatibilite_20160201" peut sembler redondante, mais en fait, elle */
/* est la au cas ou la valeur initiale ('UN') venait a changer... */
DEFV(genere_p,INIT(niveau_du_point_permute,NIVEAU_UNDEF));
DEFV(Int,INIT(point_permute_X,UNDEF));
DEFV(Int,INIT(point_permute_Y,UNDEF));
/* Coordonnees du point qui va etre permute avec le point courant {X,Y}... */
Tant(IL_FAUT(iterer_le_shuffling))
Bblock
INITIALISATION_POINT_2D(point_courant
,ADD2(X
,MUL2(facteur_des_increments_des_coordonnees
,Irandom_shuffling_____increment_1_coordonnee_X
)
)
,ADD2(Y
,MUL2(facteur_des_increments_des_coordonnees
,Irandom_shuffling_____increment_1_coordonnee_Y
)
)
);
EGAL(point_permute_X
,_cDENORMALISE_OX(NORZ(rdnI2D(ADRESSE(point_courant)
,graine
,RDN_GENERE
,FLOT__ARGUMENT_ABSENT
,FLOT__ARGUMENT_ABSENT
)
,borne_inferieure
,borne_superieure
,COORDONNEE_BARYCENTRIQUE_MINIMALE
)
)
);
INITIALISATION_POINT_2D(point_courant
,ADD2(X
,MUL2(facteur_des_increments_des_coordonnees
,Irandom_shuffling_____increment_2_coordonnee_X
)
)
,ADD2(Y
,MUL2(facteur_des_increments_des_coordonnees
,Irandom_shuffling_____increment_2_coordonnee_Y
)
)
);
EGAL(point_permute_Y
,_cDENORMALISE_OY(NORZ(rdnI2D(ADRESSE(point_courant)
,graine
,RDN_GENERE
,FLOT__ARGUMENT_ABSENT
,FLOT__ARGUMENT_ABSENT
)
,borne_inferieure
,borne_superieure
,COORDONNEE_BARYCENTRIQUE_MINIMALE
)
)
);
/* Generation d'un point aleatoire... */
begin_nouveau_block
Bblock
DEFV(Int,INIT(nombre_de_collisions_au_point_courant
,loadI_point(matrice_des_nombres_de_collisions,X,Y)
)
);
DEFV(Int,INIT(nombre_de_collisions_au_point_permute
,loadI_point(matrice_des_nombres_de_collisions,point_permute_X,point_permute_Y)
)
);
Test(IFOU(IL_FAUT(Irandom_shuffling_____compatibilite_20160201)
,IFOU(I3ET(IFLE(nombre_de_collisions_au_point_courant
,Irandom_shuffling_____nombre_maximal_de_collisions
)
,IFLE(nombre_de_collisions_au_point_permute
,Irandom_shuffling_____nombre_maximal_de_collisions
)
,IFOU(IFNE(X,point_permute_X)
,IFNE(Y,point_permute_Y)
)
)
,IFGT(nombre_courant_d_iterations_lors_des_collisions
,Irandom_shuffling_____limite_du_detecteur_de_collisions
)
)
)
)
Bblock
EGAL(niveau_du_point_permute,load_point_valide(imageA,point_permute_X,point_permute_Y));
store_point(niveau_du_point_permute,imageR,X,Y,FVARIABLE);
store_point_valide(niveau_du_point_courant,imageR,point_permute_X,point_permute_Y,FVARIABLE);
/* Permutation du point courant {X,Y} et du point aleatoire... */
storeI_point(ADD2(nombre_de_collisions_au_point_courant,I)
,matrice_des_nombres_de_collisions
,X,Y
);
storeI_point(ADD2(nombre_de_collisions_au_point_permute,I)
,matrice_des_nombres_de_collisions
,point_permute_X,point_permute_Y
);
/* Comptage des collisions... */
EGAL(iterer_le_shuffling,FAUX);
Eblock
ATes
Bblock
INCR(nombre_courant_d_iterations_lors_des_collisions,I);
INCR(facteur_des_increments_des_coordonnees,I);
Eblock
ETes
Eblock
end_nouveau_block
Eblock
ETan
Eblock
ATes
Bblock
store_point(niveau_du_point_courant,imageR,X,Y,FVARIABLE);
/* Dans le cas contraire, on conserve le point courant {X,Y} en l'etat... */
storeI_point(ADD2(loadI_point(matrice_des_nombres_de_collisions,X,Y),I)
,matrice_des_nombres_de_collisions
,X,Y
);
Eblock
ETes
Eblock
end_image
EDEFV(imageI,matrice_des_nombres_de_collisions);
RETI(imageR);
Eblock
EFonctionP
_______________________________________________________________________________________________________________________________________
_______________________________________________________________________________________________________________________________________
/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/* */
/* C H A M P C O M P L E T E M E N T A L E A T O I R E E N C O O R D O N N E E S : */
/* */
/*************************************************************************************************************************************/
BFonctionP
DEFV(Common,DEFV(genere_p,SINT(Irandom_coordonnees_____niveau_du_fond,NOIR)));
/* Introduit le 20171021105301... */
DEFV(Common,DEFV(genere_p,SINT(Irandom_coordonnees_____niveau_des_points_probables,NIVEAU_DES_POINTS_PROBABLES)));
/* Introduit le 20140807100850 par symetrie avec 'Irandom_positions(...)'. */
DEFV(Common,DEFV(Logical,SINT(Irandom_coordonnees_____unicite_des_marquages,FAUX)));
/* Introduit le 20171021105301 pour permettre de ne pas marquer plusieurs fois le meme */
/* point. Mais cet indicateur est initialise de facon a garantir la compatibilite */
/* anterieure... */
DEFV(Common,DEFV(Int,SINT(Irandom_coordonnees_____translation_de_la_graine_pour_X,TROIS)));
DEFV(Common,DEFV(Int,SINT(Irandom_coordonnees_____translation_de_la_graine_pour_Y,SEPT)));
/* Modificateurs de la graine utilisee... */
DEFV(Common,DEFV(FonctionP,POINTERp(Irandom_coordonnees(imageR,graine,nombre_de_points_a_marquer))))
/* Fonction introduite le 20030227155745. */
DEFV(Argument,DEFV(image,imageR));
/* Image Resultat, telle que : imageR[X][Y]=un point {X,Y} si la probabilite est favorable. */
DEFV(Argument,DEFV(Int,graine));
/* Graine arbitraire dont depend la generation. */
DEFV(Argument,DEFV(Positive,nombre_de_points_a_marquer));
/* Nombre de points a marquer. */
/* */
/* On notera le 20171021115651 que pour etre sur que ce nombre de points soit un nombre */
/* de points DIFFERENTS, il faut evidemment que : */
/* */
/* Irandom_coordonnees_____unicite_des_marquages=VRAI */
/* */
/* en notant que, dans ces conditions, ce nombre peut etre inatteignable s'il est proche */
/* de 'dimXY' (ou superieur evidemment...). */
/*-----------------------------------------------------------------------------------------------------------------------------------*/
Bblock
DEFV(Float,INIT(borne_inferieure,CHOI(_____cNORMALISE_OX(Xmin),_____cNORMALISE_OY(Ymin))));
/* Borne inferieure du generateur, */
DEFV(Float,INIT(borne_superieure,CHOI(_____cNORMALISE_OX(Xmax),_____cNORMALISE_OY(Ymax))));
/* Borne superieure du generateur. */
DEFV(pointI_2D,point_courant);
/* Point (entier) courant. */
DEFV(Positive,INIT(nombre_de_points_deja_marques,ZERO));
/* Pour compter les points marques... */
/*..............................................................................................................................*/
INITIALISATION_POINT_2D(point_courant,Xmin,Ymin);
CALS(rdnI2D(ADRESSE(point_courant),UNDEF,RDN_INIT,borne_inferieure,borne_superieure));
/* Initialisation du generateur aleatoire. */
begin_image
/* On notera que cette facon de faire (en balayant par {begin_image,end_image} l'integralite */
/* de l'image), alors que l'on veut en general generer un petit nombre de points aleatoires, */
/* n'est pas optimisee. Elle fut choisie pour des raisons de simplicite de programmation (en */
/* particulier a cause du point de parametrage 'point_courant' du generateur aleatoire */
/* 'rdnI2D(...)'). */
Bblock
INITIALISATION_POINT_2D(point_courant,X,Y);
Test(IFLT(nombre_de_points_deja_marques,nombre_de_points_a_marquer))
Bblock
DEFV(Logical,INIT(marquer_le_point,VRAI));
DEFV(Int,INIT(coordonnee_X
,_cDENORMALISE_OX(rdnI2D(ADRESSE(point_courant)
,ADD2(graine,Irandom_coordonnees_____translation_de_la_graine_pour_X)
,RDN_GENERE
,FLOT__ARGUMENT_ABSENT
,FLOT__ARGUMENT_ABSENT
)
)
)
);
DEFV(Int,INIT(coordonnee_Y
,_cDENORMALISE_OY(rdnI2D(ADRESSE(point_courant)
,ADD2(graine,Irandom_coordonnees_____translation_de_la_graine_pour_Y)
,RDN_GENERE
,FLOT__ARGUMENT_ABSENT
,FLOT__ARGUMENT_ABSENT
)
)
)
);
Test(IL_FAUT(Irandom_coordonnees_____unicite_des_marquages))
/* Test introduit le 20171021105301 et qui est destine a garantir qu'un meme point n'est pas */
/* marque deux fois... */
Bblock
EGAL(marquer_le_point,FAUX);
/* A priori, le point ne sra pas marque... */
Test(TEST_DANS_L_IMAGE(coordonnee_X,coordonnee_Y))
Bblock
Test(IFEQ(load_point(imageR,coordonnee_X,coordonnee_Y),Irandom_coordonnees_____niveau_du_fond))
Bblock
EGAL(marquer_le_point,VRAI);
/* Le point ne sera marque que s'il ne l'etait pas anterieurement... */
Eblock
ATes
Bblock
Eblock
ETes
Eblock
ATes
Bblock
Eblock
ETes
Eblock
ATes
Bblock
Eblock
ETes
Test(IL_FAUT(marquer_le_point))
/* Test introduit le 20171021105301 et qui permet de garantir qu'un meme point n'est pas */
/* marque deux fois... */
Bblock
store_point_valide(Irandom_coordonnees_____niveau_des_points_probables
,imageR
,coordonnee_X
,coordonnee_Y
,FVARIABLE
);
/* Generation du point courant {RDN(X),RDN(Y)}. Evidemment, on notera que, par malchance, */
/* il est possible de marquer ainsi plusieurs fois le meme point (collision des {X,Y} */
/* aleatoires calculees ci-dessus). Cela est d'autant plus probable que le nombre de */
/* points a generer ('nombre_de_points_a_marquer') est grand... */
INCR(nombre_de_points_deja_marques,I);
/* Comptage des points marques... */
Eblock
ATes
Bblock
Eblock
ETes
Eblock
ATes
Bblock
Eblock
ETes
Eblock
end_image
RETI(imageR);
Eblock
EFonctionP
_______________________________________________________________________________________________________________________________________
_______________________________________________________________________________________________________________________________________
/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/* */
/* C H A M P C O M P L E T E M E N T A L E A T O I R E E N P O S I T I O N */
/* E T F O N C T I O N D ' U N A U T R E C H A M P : */
/* */
/* */
/* # # # ### ### ### #### ### ### ######## */
/* ## # ## # # ## ### # ## # ### # # ## ### ##### */
/* # # ## #### ##### ### ## ######## #### ## */
/* # ### ## # # ## # ## # ##### ### ########## */
/* # # ## # ### ### ## # ## # #### ###### */
/* ## # # ### ## # # ##### ########## ######## */
/* # # # # ## # ## ### # #### # ##### ##### ### */
/* ### # # # # # ## # ########## # ###### ### */
/* # # ## # ## # ########## # ######## */
/* # # ##### # ## # #### # # # ############# */
/* # # # # ### # ### ### #### ## ########## */
/* # # # # ## ## ###### # #### ##### ### # #### */
/* # # # ## # ### ### # # ## ### ######### #### */
/* # # # # ### # ### # # ###################### */
/* # # ## # # # # ### ### ## ## ## #### ######## */
/* # # ##### ## # # # #### ###### ### ### ######## */
/* # ## # ## # # # # # ## ################# */
/* # # # # ### #### ####### ## ## ### ###### ### */
/* # #### ### ## ## #### # ########## #### */
/* # # ### ## # # # ### ############ ## */
/* # # # # ### ## # ## # # # # ####### */
/* # ## ## # ### ## ## ### ########### */
/* # # # # # ## #### # ## # ### ## ###### ####### */
/* # # #### # ### # ###### ######### #### */
/* # # # # # # # ## # ## #### #### #### */
/* # # # # ## # ## # ### # ## ## ### ## ###### */
/* # ## # # # ## ## ###### ######## ###### */
/* # # ## ### # ## ## # ### ################ */
/* # # # # ## # ## # ### ########## ## ##### */
/* ## # # ## # ## ## #### ######### ############# */
/* # # ### # ###### ### ## ##### #### ######### */
/* ## # ## ###### # ## # #### ### # ################ */
/* */
/* */
/* avec la contrainte ('$xiio/MIRE') suivante : */
/* */
/* */
/* ................::::::::--------++++++++oooooooo********####### */
/* ................::::::::--------++++++++oooooooo********####### */
/* ................::::::::--------++++++++oooooooo********####### */
/* ................::::::::--------++++++++oooooooo********####### */
/* ................::::::::--------++++++++oooooooo********####### */
/* ................::::::::--------++++++++oooooooo********####### */
/* ................::::::::--------++++++++oooooooo********####### */
/* ................::::::::--------++++++++oooooooo********####### */
/* ................::::::::--------++++++++oooooooo********####### */
/* ................::::::::--------++++++++oooooooo********####### */
/* ................::::::::--------++++++++oooooooo********####### */
/* ................::::::::--------++++++++oooooooo********####### */
/* ................::::::::--------++++++++oooooooo********####### */
/* ................::::::::--------++++++++oooooooo********####### */
/* ................::::::::--------++++++++oooooooo********####### */
/* ................::::::::--------++++++++oooooooo********####### */
/* ................::::::::--------++++++++oooooooo********####### */
/* ................::::::::--------++++++++oooooooo********####### */
/* ................::::::::--------++++++++oooooooo********####### */
/* ................::::::::--------++++++++oooooooo********####### */
/* ................::::::::--------++++++++oooooooo********####### */
/* ................::::::::--------++++++++oooooooo********####### */
/* ................::::::::--------++++++++oooooooo********####### */
/* ................::::::::--------++++++++oooooooo********####### */
/* ................::::::::--------++++++++oooooooo********####### */
/* ................::::::::--------++++++++oooooooo********####### */
/* ................::::::::--------++++++++oooooooo********####### */
/* ................::::::::--------++++++++oooooooo********####### */
/* ................::::::::--------++++++++oooooooo********####### */
/* ................::::::::--------++++++++oooooooo********####### */
/* ................::::::::--------++++++++oooooooo********####### */
/* ................::::::::--------++++++++oooooooo********####### */
/* */
/* */
/*************************************************************************************************************************************/
BFonctionP
DEFV(Common,DEFV(genere_p,SINT(Irandom_positions_variable_____niveau_des_points_probables,NIVEAU_DES_POINTS_PROBABLES)));
/* Introduit le 20140807100850 par symetrie avec 'Irandom_positions(...)'. */
#define SEUIL_VARIABLE_DU_GENERATEUR_ALEATOIRE \
MUL2(facteur_des_niveaux \
,______NORMALISE_NIVEAU(load_point(image_de_contrainte,X,Y)) \
) \
/* De facon a passer d'un niveau dans l'image de contrainte du generateur aleatoire a un */ \
/* seuil dans [0,1]. */
DEFV(Common,DEFV(FonctionP,POINTERp(Irandom_positions_variable(imageR
,graine
,facteur_des_niveaux
,image_de_contrainte
)
)
)
)
DEFV(Argument,DEFV(image,imageR));
/* Image Resultat, telle que : imageR[X][Y]=un point {X,Y} si la probabilite est favorable. */
DEFV(Argument,DEFV(Int,graine));
/* Graine arbitraire dont depend la generation. */
DEFV(Argument,DEFV(Float,facteur_des_niveaux));
/* Pour calculer le seuil de generation aleatoire a partir d'un niveau. */
DEFV(Argument,DEFV(image,image_de_contrainte));
/* Image contraignant le generateur aleatoire : plus un niveau est proche de 'NOIR', moins */
/* il y a de chance de generer quelque chose, alors que plus il est proche de 'BLANC', plus */
/* on a de chance ; notons que cela est a relativiser en fonction de 'facteur_des_niveaux'. */
/*-----------------------------------------------------------------------------------------------------------------------------------*/
Bblock
DEFV(Float,INIT(borne_inferieure,PROBABILITE_NULLE));
/* Borne inferieure du generateur, */
DEFV(Float,INIT(borne_superieure,PROBABILITE_UNITE));
/* Borne superieure du generateur. */
DEFV(pointI_2D,point_courant);
/* Point (entier) courant. */
/*..............................................................................................................................*/
INITIALISATION_POINT_2D(point_courant,Xmin,Ymin);
CALS(rdnI2D(ADRESSE(point_courant),UNDEF,RDN_INIT,borne_inferieure,borne_superieure));
/* Initialisation du generateur aleatoire. */
begin_image
Bblock
INITIALISATION_POINT_2D(point_courant,X,Y);
Test(IFLE(rdnI2D(ADRESSE(point_courant),graine,RDN_GENERE,FLOT__ARGUMENT_ABSENT,FLOT__ARGUMENT_ABSENT)
,SEUIL_VARIABLE_DU_GENERATEUR_ALEATOIRE
)
)
Bblock
/* Deux cas se prsentent : */
/* */
/* rdn(X,Y) <= seuil : on genere un point en {X,Y}, */
/* rdn(X,Y) > seuil : on laisse le point {X,Y} inchange. */
/* */
store_point(Irandom_positions_variable_____niveau_des_points_probables,imageR,X,Y,FVARIABLE);
/* Generation du point courant {X,Y}, lorsque la probabilite est favorable... */
Eblock
ATes
Bblock
Eblock
ETes
Eblock
end_image
RETI(imageR);
Eblock
#undef SEUIL_VARIABLE_DU_GENERATEUR_ALEATOIRE
EFonctionP
_______________________________________________________________________________________________________________________________________
_______________________________________________________________________________________________________________________________________
/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/* */
/* " S H U F F L I N G " D I R E C T D ' U N E I M A G E */
/* C O N S E R V A N T L E N O M B R E D E P O I N T S D E N I V E A U D O N N E : */
/* */
/*************************************************************************************************************************************/
/* 'Ishuffling_direct(...)' a ete deplace vers 'v $xiii/di_image$FON' le 20081008115932 */
/* a cause de 'Iegalisation_d_histogrammme_plat(...)' qui l'utilise alors. Du coup, tous */
/* les '$K' qui referencent 'image_image_DI_IMAGE_EXT' (c'est-a-dire tous...) demandaient */
/* aussi 'image_image_ALEATOIRES_1_EXT'. Pour ne pas avoir a tout recompiler, la fonction */
/* 'Ishuffling_direct(...)' a donc ete deplacee... */
_______________________________________________________________________________________________________________________________________
_______________________________________________________________________________________________________________________________________
/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/* */
/* " S H U F F L I N G " " I N V E R S E " D ' U N E I M A G E */
/* N E C O N S E R V A N T P A S L E N O M B R E D E P O I N T S D E N I V E A U D O N N E : */
/* */
/*************************************************************************************************************************************/
BFonctionP
DEFV(Common,DEFV(Logical,SINT(Ishuffling_inverse_____compatibilite_20040106,FAUX)));
/* Permet de generer des images suivant la methode anterieure au 20040106133459 en */
/* ce qui concerne la modification de la graine en fonction des coordonnees {X,Y}. */
/* Anterieurement au 20040106133459 cette facon de modifier la graine faisait que pour */
/* les points de la droite Y=X la graine etait modifiee identiquement pour les deux */
/* coordonnees 'X' et 'Y'. A compter de cette date, la pertubation apportee a la graine */
/* passe donc de {+X,+Y} a {-X,+Y} ce qui, etant donne que les coordonnees sont positives, */
/* ne peut jamais donner la meme graine "effective" : 'graine-X' et 'graine+Y' ne peuvent */
/* etre egaux puisque l'on ne peut avoir Y=-X... */
DEFV(Common,DEFV(FonctionP,POINTERp(Ishuffling_inverse(imageR,imageA,graine,force_le_long_de_OX,force_le_long_de_OY))))
DEFV(Argument,DEFV(image,imageR));
/* Image Resultat, telle que : imageR[X][Y]=imageA[X+rdn(X,Y)][Y+rdn(X,Y)]. */
DEFV(Argument,DEFV(image,imageA));
/* Image Argument a "shuffliser"... */
DEFV(Argument,DEFV(Int,graine));
/* Graine arbitraire dont depend la generation. */
DEFV(Argument,DEFV(Float,force_le_long_de_OX));
DEFV(Argument,DEFV(Float,force_le_long_de_OY));
/* Force de la "shufflisation" dans [0,1] le long des axes 'OX' et 'OY' respectivement ; les */
/* valeurs suivantes donnent : */
/* */
/* force{X,Y}=0 : (imageR)=(imageA) (pas de "shufflisation"), */
/* force{X,Y}=1 : la "shufflisation" est maximale... */
/* */
/* Evidemment, lorsque ces deux parametres sont egaux, la force est "isotrope"... */
/*-----------------------------------------------------------------------------------------------------------------------------------*/
Bblock
DEFV(pointI_2D,point_courant);
/* Point (entier) courant. */
SPIRALE_DEFINITION
/* Donnees de generation d'une spirale de parcours d'une image. */
/*..............................................................................................................................*/
SPIRALE_VALIDATION;
/* Validation des pas de parcours (pasX,pasY) des images. */
CALS(Inoir(imageR));
/* Initialisation du resultat. */
INITIALISATION_POINT_2D(point_courant,Xmin,Ymin);
CALS(rdnI2D(ADRESSE(point_courant)
,UNDEF
,RDN_INIT
,FLOT(NEGA(PLUS_PETITE_IMAGE_CARREE_CIRCONSCRITE))
,FLOT(PLUS_PETITE_IMAGE_CARREE_CIRCONSCRITE)
)
);
/* Initialisation du generateur aleatoire. */
begin_image
Bblock
SPIRALE_REINITIALISATION_BRAS;
/* Reinitialisation de la spirale en son centre, sans reinitialiser la direction */
/* et le sens du bras courant... */
INITIALISATION_POINT_2D(point_courant
,ADD2(X
,INTE(MUL2(force_le_long_de_OX
,rdnI2D(ADRESSE(point_courant)
,COND(IL_FAUT(Ishuffling_inverse_____compatibilite_20040106)
,ADD2(graine,X)
,ADD2(graine,NEGA(X))
)
,RDN_GENERE
,FLOT__ARGUMENT_ABSENT
,FLOT__ARGUMENT_ABSENT
)
)
)
)
,ADD2(Y
,INTE(MUL2(force_le_long_de_OY
,rdnI2D(ADRESSE(point_courant)
,COND(IL_FAUT(Ishuffling_inverse_____compatibilite_20040106)
,ADD2(graine,Y)
,ADD2(graine,NEUT(Y))
)
,RDN_GENERE
,FLOT__ARGUMENT_ABSENT
,FLOT__ARGUMENT_ABSENT
)
)
)
)
);
/* Ainsi, on deplace aleatoirement le point courant {X,Y} ; la modification */
/* de "graine" par 'X' puis 'Y' est destinee a produire deux valeurs aleatoires */
/* differentes pour les abscisses et les ordonnees. */
Tant(TEST_HORS_IMAGE(ASD1(point_courant,x),ASD1(point_courant,y)))
Bblock
/* Ainsi, on cherche "en spirale" le premier point qui soit dans l'image... */
SPIRALE_INITIALISATION;
/* Initialisation dynamique de 'spirale_nombre_de_points_a_traiter'. */
SPIRALE_DEPLACEMENT(ASD1(point_courant,x),ASD1(point_courant,y));
/* Deplacement du point courant de la spirale... */
/* ATTENTION : on n'utilise pas 'SPIRALE_DEPLACEMENT_ET_PARCOURS(...)' afin de garantir la */
/* terminaison du processus 'Tant(...)'. */
SPIRALE_PARCOURS;
/* Parcours de la spirale avec rotation eventuelle de PI/2 du bras courant... */
Eblock
ETan
store_point(load_point(imageA,ASD1(point_courant,x),ASD1(point_courant,y)),imageR,X,Y,FVARIABLE);
/* Ainsi, on deplace aleatoirement le point courant {X,Y}, */
/* */
/* ATTENTION : en procedant ainsi, on notera que plusieurs points {X,Y} differents peuvent */
/* etre positionnes avec un meme 'point_courant' ; cela fait donc que le nombre de points */
/* de niveau donne n'est pas conserve en passant de 'imageA' a 'imageR' (au passage, ce */
/* nombre augmente a priori...). C'est la la difference fondamentale avec la fonction */
/* 'Ishuffling_direct(...)'. */
Eblock
end_image
RETI(imageR);
Eblock
EFonctionP
_______________________________________________________________________________________________________________________________________
_______________________________________________________________________________________________________________________________________
/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/* */
/* D E F I N T I O N S U T I L E S A L A D I S P E R S I O N D ' U N E I M A G E F L O T T A N T E : */
/* */
/*************************************************************************************************************************************/
#define GRAINE_COURANTE \
ADD2(graine,INCR(increment_de_la_graine,I)) \
/* Graine courante a utiliser, fonction de l'instruction courante... */
#define VERIFICATIONS_DE_LA_DISPERSION_ALEATOIRE_D_UNE_IMAGE \
Bblock \
Test(IZLE(nombre_de_points_du_nuage)) \
Bblock \
PRINT_ATTENTION("le nombre de points du nuage doit etre strictement positif"); \
Eblock \
ATes \
Bblock \
Eblock \
ETes \
\
Test(IFLT(dispersion_superieure_des_X,dispersion_inferieure_des_X)) \
Bblock \
PRINT_ATTENTION("la dispersion des coordonnees 'X' est mal definie"); \
Eblock \
ATes \
Bblock \
Eblock \
ETes \
\
Test(IFLT(dispersion_superieure_des_Y,dispersion_inferieure_des_Y)) \
Bblock \
PRINT_ATTENTION("la dispersion des coordonnees 'Y' est mal definie"); \
Eblock \
ATes \
Bblock \
Eblock \
ETes \
\
Test(IFLT(dispersion_superieure_des_niveaux,dispersion_inferieure_des_niveaux)) \
Bblock \
PRINT_ATTENTION("la dispersion des niveaux est mal definie"); \
Eblock \
ATes \
Bblock \
Eblock \
ETes \
Eblock
#define DISPERSION_ALEATOIRE_D_UN_POINT_D_UNE_IMAGE \
Bblock \
DEFV(genere_Float,INIT(niveau_courant,loadF_point(imageA,X,Y))); \
/* Niveau du point courant {X,Y} a disperser... */ \
DEFV(Int,INIT(increment_de_la_graine,ZERO)); \
/* Afin de faire varier la graine a chaque appel du generateur aleatoire. */ \
\
DEFV(pointI_2D,point_courant); \
INITIALISATION_POINT_2D(point_courant,X,Y); \
/* Point (entier) courant destine a parametrer le generateur aleatoire. */ \
\
Repe(nombre_de_points_du_nuage) \
Bblock \
DEFV(genere_Float,INIT(niveau_courant_dispersee,FLOT__NIVEAU_UNDEF)); \
DEFV(Int,INIT(coordonnee_X_dispersee,UNDEF)); \
DEFV(Int,INIT(coordonnee_Y_dispersee,UNDEF)); \
/* Definition du point "dispersee" courant. */ \
DEFV(genere_Float,INIT(niveau_anterieur,FLOT__NIVEAU_UNDEF)); \
/* Niveau anterieur du point de coordonnees "dispersees". */ \
\
EGAL(coordonnee_X_dispersee \
,rdnI2D(ADRESSE(point_courant) \
,GRAINE_COURANTE \
,RDN_INIT_AND_GENERE \
,FLOT(ADD2(X,dispersion_inferieure_des_X)) \
,FLOT(ADD2(X,dispersion_superieure_des_X)) \
) \
); \
EGAL(coordonnee_Y_dispersee \
,rdnI2D(ADRESSE(point_courant) \
,GRAINE_COURANTE \
,RDN_INIT_AND_GENERE \
,FLOT(ADD2(Y,dispersion_inferieure_des_Y)) \
,FLOT(ADD2(Y,dispersion_superieure_des_Y)) \
) \
); \
/* "Dispersion" des coordonnees {X,Y}. */ \
\
Test(TEST_DANS_L_IMAGE(coordonnee_X_dispersee,coordonnee_Y_dispersee)) \
Bblock \
/* Cas ou la dispersion nous maintient dans l'image : */ \
DEFV(pointF_2D,point_courant_flottant); \
TRANSFERT_POINT_2D(point_courant_flottant,point_courant); \
/* Introduit le 20040618134003 car manquait alors... */ \
\
EGAL(niveau_courant_dispersee \
,rdnF2D(ADRESSE(point_courant_flottant) \
,GRAINE_COURANTE \
,RDN_INIT_AND_GENERE \
,ADD2(niveau_courant,dispersion_inferieure_des_niveaux) \
,ADD2(niveau_courant,dispersion_superieure_des_niveaux) \
) \
); \
/* "Dispersion" des coordonnees {X,Y}. */ \
\
EGAL(niveau_anterieur,loadF_point(imageR,coordonnee_X_dispersee,coordonnee_Y_dispersee)); \
/* Niveau anterieur du point de coordonnees "dispersees". */ \
\
storeF_point(COND(IL_FAUT(prendre_le_maximum) \
,MAX2(niveau_anterieur,niveau_courant_dispersee) \
,ADD2(niveau_anterieur,niveau_courant_dispersee) \
) \
,imageR \
,coordonnee_X_dispersee,coordonnee_Y_dispersee \
); \
/* Et dispersion... */ \
Eblock \
ATes \
Bblock \
/* Cas ou la dispersion nous fait sortir de l'image : rien a faire... */ \
Eblock \
ETes \
Eblock \
ERep \
Eblock
/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/* */
/* D I S P E R S I O N ( " S P R A Y " ) D ' U N E I M A G E F L O T T A N T E : */
/* */
/*************************************************************************************************************************************/
BFonctionF
DEFV(Common,DEFV(FonctionF,POINTERF(IFdispersion_aleatoire(imageR,imageA
,graine
,nombre_de_points_du_nuage
,dispersion_inferieure_des_X,dispersion_superieure_des_X
,dispersion_inferieure_des_Y,dispersion_superieure_des_Y
,dispersion_inferieure_des_niveaux,dispersion_superieure_des_niveaux
,prendre_le_maximum
)
)
)
)
DEFV(Argument,DEFV(imageF,imageR));
/* Image Resultat, telle que : imageR[X][Y]=imageA[X][Y] "traduit" en un nuage de points. */
DEFV(Argument,DEFV(imageF,imageA));
/* Image Argument. */
DEFV(Argument,DEFV(Int,graine));
/* Graine arbitraire dont depend la generation. */
DEFV(Argument,DEFV(Int,nombre_de_points_du_nuage));
/* Nombre de points du nuage a generer. */
DEFV(Argument,DEFV(Int,dispersion_inferieure_des_X));
DEFV(Argument,DEFV(Int,dispersion_superieure_des_X));
/* Definition de la dispersion des coordonees 'X'. */
DEFV(Argument,DEFV(Int,dispersion_inferieure_des_Y));
DEFV(Argument,DEFV(Int,dispersion_superieure_des_Y));
/* Definition de la dispersion des coordonees 'Y'. */
DEFV(Argument,DEFV(Float,dispersion_inferieure_des_niveaux));
DEFV(Argument,DEFV(Float,dispersion_superieure_des_niveaux));
/* Definition de la dispersion des niveaux. */
/* */
/* Le 20100423100442 la dispersion des niveaux est passee de 'Int' a 'Float' plus logique */
/* puisque les images sont de type 'imageF'... */
DEFV(Argument,DEFV(Logical,prendre_le_maximum));
/* Indique s'il faut prendre le maximum entre la valeur courante et la valeur anterieure */
/* ('VRAI') ou proceder a un cumul arithmetique ('FAUX'). */
/*-----------------------------------------------------------------------------------------------------------------------------------*/
Bblock
/*..............................................................................................................................*/
VERIFICATIONS_DE_LA_DISPERSION_ALEATOIRE_D_UNE_IMAGE;
/* Introduit sous cette forme le 20170402094945... */
begin_image_AvecEditionProgression
/* Le 20170523174309 "_AvecEditionProgression" a ete introduit pour des tests "symetriques" */
/* avec ceux de 'IFdispersion_aleatoire_back(...)'... */
Bblock
DISPERSION_ALEATOIRE_D_UN_POINT_D_UNE_IMAGE;
/* Introduit sous cette forme le 20170402094945... */
Eblock
end_image_AvecEditionProgression
/* Le 20170523174309 "_AvecEditionProgression" a ete introduit pour des tests "symetriques" */
/* avec ceux de 'IFdispersion_aleatoire_back(...)'... */
RETIF(imageR);
Eblock
EFonctionF
/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/* */
/* D I S P E R S I O N " B A C K " ( " S P R A Y " ) D ' U N E I M A G E F L O T T A N T E : */
/* */
/*************************************************************************************************************************************/
BFonctionF
DEFV(Common,DEFV(FonctionF,POINTERF(IFdispersion_aleatoire_back(imageR,imageA
,graine
,nombre_de_points_du_nuage
,dispersion_inferieure_des_X,dispersion_superieure_des_X
,dispersion_inferieure_des_Y,dispersion_superieure_des_Y
,dispersion_inferieure_des_niveaux,dispersion_superieure_des_niveaux
,prendre_le_maximum
)
)
)
)
/* Fonction introduite le 20170402100346 uniquement pour tester 'PROGRESSION_DES_BEGIN_END' */
/* dans le cas {begin_image_back,end_image_back}... */
DEFV(Argument,DEFV(imageF,imageR));
/* Image Resultat, telle que : imageR[X][Y]=imageA[X][Y] "traduit" en un nuage de points. */
DEFV(Argument,DEFV(imageF,imageA));
/* Image Argument. */
DEFV(Argument,DEFV(Int,graine));
/* Graine arbitraire dont depend la generation. */
DEFV(Argument,DEFV(Int,nombre_de_points_du_nuage));
/* Nombre de points du nuage a generer. */
DEFV(Argument,DEFV(Int,dispersion_inferieure_des_X));
DEFV(Argument,DEFV(Int,dispersion_superieure_des_X));
/* Definition de la dispersion des coordonees 'X'. */
DEFV(Argument,DEFV(Int,dispersion_inferieure_des_Y));
DEFV(Argument,DEFV(Int,dispersion_superieure_des_Y));
/* Definition de la dispersion des coordonees 'Y'. */
DEFV(Argument,DEFV(Float,dispersion_inferieure_des_niveaux));
DEFV(Argument,DEFV(Float,dispersion_superieure_des_niveaux));
/* Definition de la dispersion des niveaux. */
DEFV(Argument,DEFV(Logical,prendre_le_maximum));
/* Indique s'il faut prendre le maximum entre la valeur courante et la valeur anterieure */
/* ('VRAI') ou proceder a un cumul arithmetique ('FAUX'). */
/*-----------------------------------------------------------------------------------------------------------------------------------*/
Bblock
/*..............................................................................................................................*/
VERIFICATIONS_DE_LA_DISPERSION_ALEATOIRE_D_UNE_IMAGE;
begin_image_back_AvecEditionProgression
/* Le 20170523173621 "_AvecEditionProgression" a ete introduit pour le tester dans cette */
/* fonction dont le role est precisemment de tester 'PROGRESSION_DES_BEGIN_END'... */
Bblock
DISPERSION_ALEATOIRE_D_UN_POINT_D_UNE_IMAGE;
Eblock
end_image_back_AvecEditionProgression
/* Le 20170523173621 "_AvecEditionProgression" a ete introduit pour le tester dans cette */
/* fonction dont le role est precisemment de tester 'PROGRESSION_DES_BEGIN_END'... */
RETIF(imageR);
Eblock
EFonctionF
#undef VERIFICATIONS_DE_LA_DISPERSION_ALEATOIRE_D_UNE_IMAGE
#undef DISPERSION_ALEATOIRE_D_UN_POINT_D_UNE_IMAGE
#undef GRAINE_COURANTE
_______________________________________________________________________________________________________________________________________