/*************************************************************************************************************************************/
/* */
/* C A L C U L D ' U N R I D E A U F R A C T A L D E B E N O I T C L O I T R E : */
/* */
/* */
/* Nota : */
/* */
/* Ce programme fait suite a l'article */
/* 'v $Dcourrier_in/20131107103657 Cloitre.Fractalcurtains.3-11-2013b.pdf' */
/* transmis par Jean-Paul Delahaye... */
/* */
/* */
/* Author of '$xtc/RideauxFractals.12$c' : */
/* */
/* Jean-Francois COLONNA (LACTAMME, 20131109091751). */
/* */
/*************************************************************************************************************************************/
#include <stdio.h>
#include "INCLUDES.01.I"
extern void *malloc();
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 dimXY \
(dimY*dimX*sizeof(PRECIS))
#define MATRICE(x,y) \
(*(matrice + (((y-Ymin)*dimX) + (x-Xmin))))
/* Acces a un point de la matrice. */
#define PRECIS double
#define CAST(x) ((PRECIS)(x))
#define FRACT(x) ((x)-((int)(x)))
#ifndef EPSILON
# define EPSILON (1.0e-8)
#else
#endif
#ifndef PASSIGMA
# define PASSIGMA (1)
#else
#endif
#ifndef NOMBRE_R0
# define NOMBRE_R0 (2.71828182)
#else
#endif
#ifndef NOMBRE_RN
# define NOMBRE_RN (2.71828183)
#else
#endif
#ifndef NOMBRE_X0
# define NOMBRE_X0 (86000)
#else
#endif
#ifndef NOMBRE_XN
# define NOMBRE_XN (129624)
#else
#endif
PRECIS constante_cr;
PRECIS fonction(PRECIS x,PRECIS r)
{
PRECIS ValeurFonction;
int i;
ValeurFonction=-((constante_cr*x)/CAST(PASSIGMA));
for (i=1 ; i<=(int)x ; i=i+PASSIGMA)
{
ValeurFonction = ValeurFonction + FRACT(((PRECIS)i)*r);
}
return(ValeurFonction);
}
main()
{
int x,y;
/* Definition des coordonnees. */
PRECIS *matrice;
/* Definition de la matrice a generer... */
Get(dimX,"dimX");
Get(dimY,"dimY");
/* Recuperation des dimensions en 'X' et en 'Y' de la matrice a generer... */
matrice=malloc(dimXY);
/* Definition de l'image a generer... */
for (y=Ymin ; y<=Ymax ; y++)
{
PRECIS nombre_r=((y*(NOMBRE_RN-NOMBRE_R0))+(NOMBRE_R0*Ymax)-(NOMBRE_RN*Ymin))/CAST(Ymax-Ymin);
/* Cette interpolation doit etre ecrite ainsi et non pas : */
/* */
/* ((NOMBRE_RN*CAST(y-Ymin))+(NOMBRE_R0*CAST(Ymax-y)))/CAST(Ymax-Ymin) */
/* */
/* si l'on veut que 'nombre_r' soit constant lorsque 'NOMBRE_R0' et 'NOMBRE_RN' sont egaux. */
int n=1;
int iterer=VRAI;
constante_cr=0;
while (iterer == VRAI)
{
PRECIS new_constante_cr=constante_cr + FRACT(((PRECIS)n)*nombre_r);
if (ABSO(constante_cr-new_constante_cr) < EPSILON)
{
iterer = FAUX;
}
else
{
constante_cr = new_constante_cr;
n++;
}
}
constante_cr=constante_cr/((PRECIS)n);
for (x=Xmin ; x<=Xmax ; x++)
{
int nombre_x=((x*(NOMBRE_XN-NOMBRE_X0))+(NOMBRE_X0*Xmax)-(NOMBRE_XN*Xmin))/CAST(Xmax-Xmin);
/* Cette interpolation doit etre ecrite ainsi et non pas : */
/* */
/* ((NOMBRE_XN*CAST(x-Xmin))+(NOMBRE_X0*CAST(Xmax-x)))/CAST(Xmax-Xmin) */
/* */
/* si l'on veut que 'nombre_x' soit constant lorsque 'NOMBRE_X0' et 'NOMBRE_XN' sont egaux. */
MATRICE(x,y) = fonction(CAST(nombre_x),nombre_r);
}
}
write(1,matrice,dimXY);
/* Sortie de la matrice... */
}