// Calculation Program for displaying an original egg-shaped-curve(Itou's), 06 (Thurs.) May., 2010
// in the case that a=0.5, b=0.37
// file name: C_program_3_E.c
#include< stdio.h>
#include< math.h>
void main(void)
{
double x,y,a,b,pi;
double t,dt;
int i,imax;
double xx[10001],yy[10001];// Take care of the upper limit of storage memory capacitance.
FILE *fp;
// Setting of the constants
pi=3.1415927;
a=.5;
b=.37;
printf("a=%f\n\n",a);
// Setting of the other parameters
dt=pi/2000;// plotting interval of t
i=0;
// execution of calculation
for(t=-2*pi;t<=2*pi;t=t+dt)
{
i++;
x=a*cos(t);
y=b*cos(t/4)*sin(t);
xx[i]=x;
yy[i]=y;
printf("i=%d,x=%f,y=%f\n",i,x,y);
}
imax=i;
// writing the calculated coordinates data of the curve 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\n",xx[i],yy[i]);
}
fflush(fp);
fclose(fp);
}
printf("end\n");
}// the end of the program
RETURN