/*************************************************************************************************************************************/
/* */
/* G E N E R A T I O N D U P R O F I L D E L ' I N F L A T I O N C O S M I Q U E : */
/* */
/* */
/* Author of '$xtc/inflation.11$c' : */
/* */
/* Jean-Francois COLONNA (LACTAMME, 20130219091214). */
/* */
/*************************************************************************************************************************************/
#include "INCLUDES.01.I"
/* Introduit le 20051116101528... */
extern void *malloc();
extern double pow();
extern double sin();
extern double tanh();
static int dimX=0;
#define Xmin 0
#define Xmax (Xmin + (dimX-1))
/* Definition des abscisses. */
static int dimY=0;
#define Ymin 0
#define Ymax (Ymin + (dimY-1))
/* Definition des ordonnees. */
#define IMAGE(x,y) \
(*(image + ((((y)-Ymin)*dimX) + ((x)-Xmin)))) \
/* Acces a un point de l'image. */
#define store(n,x,y) \
{ \
if ((((x)>=Xmin) && ((x)<=Xmax)) && (((y)>=Ymin) && ((y)<=Ymax))) \
{ \
IMAGE(x,y) = n; \
} \
else \
{ \
} \
} \
/* Rangement d'un point valide d'une image. */
#define nCX (((double)(x-Xmin) / (double)(Xmax-Xmin))*(XD-XG) + XG)
#define nCY (((double)(y-Ymin) / (double)(Ymax-Ymin))*(YH-YB) + YB)
/* Definition des coordonnees normalisees. */
#define dCX (int)(((double)(cx-XG) / (double)(XD-XG))*(Xmax-Xmin) + Xmin)
#define dCY (int)(((double)(cy-YB) / (double)(YH-YB))*(Ymax-Ymin) + Ymin)
/* Definition des coordonnees denormalisees. */
#define XG (0)
#define XD (1)
/* Extremites Gauche et Droite sur l'axe des 'X'. */
#define YB (0)
#define YH (1)
/* Extremites Bas et Haut sur l'axe des 'Y'. */
#define pA 1
#define pB 20
#define pC 0.4
#define pD 0.4
#define pE 4
#define pF 4
#define pG 2
#define pH 2
#define pI 0.2
#define pJ 0.2
#define pK 0.2
#define pL 1
#define F1(x) ((pA+tanh(pB*(x-pD)+pE))/pF)
#define F2(x) pI*(pow(pG*(x-pC),pH))
#define F3(x) ((pJ*x*x)+(pK*x)+pL)
#define F(x) F3(x)*COND((x < pC),F1(x),F1(pC)+F2(x))
/* Fonctions a coller bout a bout... */
main()
{
int x,y;
/* Definition des coordonnees. */
unsigned char *image;
/* Definition de l'image a generer... */
Get(dimX,"dimX");
Get(dimY,"dimY");
/* Recuperation des dimensions en 'X' et en 'Y' de l'image a generer. */
image=malloc(dimY*dimX);
/* Definition de l'image a generer... */
for (y=Ymin ; y<=Ymax ; y++)
{
for (x=Xmin ; x<=Xmax ; x++)
{
store(NOIR,x,y);
/* Nettoyage... */
}
}
for (x=Xmin ; x<=Xmax ; x++)
{
double cx=nCX;
double cy;
cy=F(cx);
store(BLANC,x,dCY);
}
write(1,image,dimX*dimY);
/* Sortie de l'image... */
}