// Calculation Program for displaying four spacies of egg-shaped-curves (Itou's) simultaneousely, 28(Fri.) Mar., 2008
// in the case that a=0.5, b=0.11~0.5
// file name: C_program_2_E.c
#include< stdio.h>
#include< math.h>
void main(void)
{
double x,y,a,b,db,bmax,pi;
double t,dt;
int i,imax,n,nmax;
double xx[10001],yy[10][10001];// Take care of the upper limit of storage memory capacitance.
FILE *fp;
// setting of the constants
pi=3.1415927;
a=.5;
bmax=a;
db=0.13;// selected interval of parameter b
// setting of the other parameters
dt=pi/1000;// plotting interval of t
i=0;
// execution of calculation
for(t=-pi;t<=pi;t=t+dt)
{
i++;
n=0;
for(b=bmax-3*db;b<=bmax+0.01;b=b+db)
{
n++;
x=a*cos(t);
y=b*cos(t/4)*sin(t);
xx[i]=x;
yy[n][i]=y;
printf("i=%d,x=%f,y=%f\n",i,x,y);
}
}
imax=i;
nmax=n;
// writing the calculated coordinates data of the curves into a textfile
fp=fopen("egg_shaped_curve.txt","w");
if(fp==NULL)
{
printf("FILE OPEN ERROR\n");
}
else
{
for(i=1;i<=imax;i++)
{
fprintf(fp,"%f,%f,%f,%f,%f\n",xx[i],yy[1][i],yy[2][i],yy[3][i],yy[4][i]);
}
fflush(fp);
fclose(fp);
}
printf("end\n");
}// the end of the program
RETURN