md-fourier-ea {
// Michèle Dessureault, sept 2000
//
// - D'après les pages 474ss des Standard Mathematical Tables
// 22ème édition
// - From the Standard Mathematical Tables, 22nd edition, pp474
// and following
//
// 4 premiers termes de l'équation générale des séries de Fourier:
// 4 first terms of Fourier Series general equation:
// a0/2 + a1*cos(pi*#z/L)+ b1*sin(#pi*#z/L) +
// a2*cos(2*pi*#z/L)+ b2*sin(2*#pi*#z/L) +
// a3*cos(3*pi*#z/L)+ b3*sin(3*#pi*#z/L) +
// a4*cos(4*pi*#z/L)+ b4*sin(4*#pi*#z/L)
//
complex Var_x,Var_y;
int temp1;
complex temp2;
double signe;
complex temp3;
complex w;
bool est_pair;
int iter;
double phi;
double path,diff;
complex oldz;
double bailtest;
double bi;
parameter complex bornes;
double bs;
parameter double a0,a1;
parameter double l;
parameter double b1,a2,b2,a3,b3,a4,b4;
parameter complex offset;
parameter int coord;
complex rho;
complex theta;
parameter int barn;
parameter double barn_offset;
parameter int pairimp;
parameter bool sgn;
parameter int intf,test;
parameter double bailout;
void init(void)
{
z=pixel;
Var_x=(0.0,0.0);
Var_y=(0.0,0.0);
temp1= 0;
temp2= (0.0,0.0);
signe= 1.0;
temp3= (0.0,0.0);
w= (0.0,0.0);
est_pair= true;
iter= 0;
phi= 0.0;
path= 0.0;
diff= 0.0;
oldz= z;
bailtest= 0.0;
bi= real(bornes);
bs= imag(bornes);
}
void loop(void)
{
w= a0/2 + a1*cos(pi*z/l)+ b1*sin(pi*z/l);
w= w+a2*cos(2*pi*z/l)+ b2*sin(2*pi*z/l);
w= w+a3*cos(3*pi*z/l)+ b3*sin(3*pi*z/l);
w= w+a4*cos(4*pi*z/l)+ b4*sin(4*pi*z/l) + offset;
Var_x=real(w);
Var_y=imag(w);
if (coord== 1)
{
rho= sqrt(sqr(Var_x)+sqr(Var_y));
theta= atan2(Var_y/Var_x);
if (theta< 0)
{
theta= theta+ 2 * pi;
}
Var_x= rho;
Var_y= theta;
}
else if (coord==2)
{
rho= sqrt(sqr(Var_x)+sqr(Var_y));
Var_x= rho* cosh(real(z));
Var_y= rho* sinh(imag(z));
}
z= fnx(Var_x) + fny(Var_y* 1i);
iter=iter+ 1;
path= path+ cabs(z);
phi= atan2(z);
phi= phi/pi;
if (phi< 0.0)
{
phi= phi+ 2.0;
}
if ((barn== 1 && real(z) >= barn_offset) || (barn== 2 && imag(z) >= barn_offset) || (barn== 3 && (real(z) * imag(z)) >= barn_offset) || (barn== 4 && (real(z) + imag(z)) >= barn_offset) || (barn== 5 && diff>= barn_offset) || (barn== 6 && phi>= barn_offset) || (barn== 7 && cabs(z) >= barn_offset) || (barn== 8 && path>= barn_offset) || (barn== 9 && iter>= barn_offset))
{
z= fnb(z);
}
if (pairimp> 0)
{
if (pairimp== 1)
{
temp2= real(z);
}
else if (pairimp== 2)
{
temp2= imag(z);
}
else if (pairimp== 3)
{
temp2= real(z) * imag(z);
}
else if (pairimp== 4)
{
temp2= real(z) + imag(z);
}
else if (pairimp== 5)
{
temp2= diff;
}
else if (pairimp== 6)
{
temp2= phi;
}
else if (pairimp== 7)
{
temp2= cabs(z);
}
else if (pairimp==
{
temp2= path;
}
else if (pairimp== 9)
{
temp2= iter;
}
if (sgn== true)
{
temp3= real(z) * imag(z);
if (temp3< 0)
{
signe= -1.0;
}
}
if (intf== 0)
{
temp1= ceil(signe*cabs(temp2));
}
else if (intf== 1)
{
temp1= floor(signe*cabs(temp2));
}
else if (intf== 2)
{
temp1= trunc(signe*cabs(temp2));
}
else if (intf== 3)
{
temp1= round(signe*cabs(temp2));
}
if (temp1% 2 == 0)
{
est_pair= true;
}
else
{
est_pair= false;
}
if (est_pair)
{
z= fnpi(z);
}
}
diff= cabs(z-oldz);
oldz= z;
Var_x= real(z);
Var_y= imag(z);
if (!((bi==0)&&(bs==0)))
{
if (((((Var_x-Var_y)>bi) && ((Var_x-Var_y)<bs)) || (((Var_x+Var_y)>bi) && ((Var_x+Var_y)<bs))))
{
z=1E6; //forces escape
}
}
if (test== 0)
{
bailtest= |z|;
}
else if (test== 1)
{
bailtest= sqr(real(z));
}
else if (test== 2)
{
bailtest= sqr(imag(z));
}
else if (test== 5)
{
bailtest= sqr(abs(real(z)) + abs(imag(z)));
}
else if (test== 6)
{
bailtest= sqr(real(z) + imag(z));
}
else if (test== 7)
{
bailtest= |z|+iter^2;
}
else if (test==
{
bailtest= |z|+phi^2;
}
else if (test== 9)
{
bailtest= |z|+path^2;
}
else if (test== 10)
{
bailtest= |z|+diff^2;
}
else if (test== 11)
{
bailtest= sqr(abs(real(z))- abs(imag(z)));
}
else if (test== 12)
{
bailtest= sqr(abs(real(z))* abs(imag(z)));
}
else if (test== 13)
{
bailtest= sqr(abs(real(z))/ abs(imag(z)));
}
else if (test== 14)
{
bailtest= sqr(abs(real(z))^ abs(imag(z)));
}
else if (test== 15)
{
bailtest= sqr(abs(imag(z))^ abs(real(z)));
}
}
bool bailout(void)
{
return((test== 3 && fnbl(sqr(real(z))) <= bailout&& fnbl(sqr(imag(z))) < bailout) || (test== 4 && (fnbl(sqr(real(z))) <= bailout|| fnbl(sqr(imag(z))) < bailout)) || (test< 3 || test>4) && fnbl(bailtest) <= bailout);
}
void description(void)
{
this.title="Fourier";
this.method = "multipass";
this.periodicity = 0;
this.magn = 2;
this.helpfile="mde-help\mde-fourier-ufm.htm";
a0.caption = "A0";
a0.default = 1.0;
a1.caption = "A1";
a1.default = 1.0;
b1.caption = "B1";
b1.default = 0.0;
a2.caption = "A2";
a2.default = 1.0;
b2.caption = "B2";
b2.default = 0.0;
a3.caption = "A3";
a3.default = 1.0;
b3.caption = "B3";
b3.default = 0.0;
a4.caption = "A4";
a4.default = 1.0;
b4.caption = "B4";
b4.default = 0.0;
l.caption = "Wavelength";
l.default = 1.0;
offset.caption = "Offset";
offset.default = (0.0,0.0);
coord.caption = "Coordinates";
coord.enum="Cartesian\nPolar\nHyperbolic";
coord.default = 0;
barn.caption = "Barnsley type";
barn.enum = "none\nreal\nimag\nreal*imag\nreal+imag\ndiff\nangle\nmagnitude\npath\niteration";
barn_offset.caption = "Barnsley Offset";
barn_offset.default = 0.0;
pairimp.caption = "Odd-Even type";
pairimp.enum = "none\nreal\nimag\nreal*imag\nreal+imag\ndiff\nangle\nmagnitude\npath\niteration";
intf.caption = "Odd-Even factor";
intf.enum = "ceil\nfloor\ntrunc\nround";
sgn.caption = "Apply Odd-even Sign?";
sgn.default = false;
bornes.caption ="Escape Range";
bornes.default = (0.0,0.0);
bailout.caption = "Bailout Value";
bailout.default = 4.0;
bailout.min = 1.0;
test.caption = "Bailout Test";
test.enum = "mod\nreal\nimag\nor\nand\nmanh\nmanr\niter\nangle\npath\ndiff\nminus\nproduct\ndivision\nreal^imag\nimag^real";
test.hint = "This gives a choice of test conditions for bailing out";
fnx.caption = "Apply F(x)";
fnx.default = "ident" ;
fny.caption = "Apply F(y)";
fny.default = "ident" ;
fnb.caption = "Barnsley Function";
fnb.default = "flip" ;
fnpi.caption = "Odd-even Function";
fnpi.default = "flip" ;
fnbl.caption = "Bailout Function";
fnbl.default = "ident" ;
fnbl.hint = "To choose some function for further bailout tests";
}
}
thas is the code from Chaos pro witch make the Fourier
I hope it help
ERIC