// Calculation Program for displaying a single egg-shaped-curve, 19(Wed) March, 2008
// In the case of a=1, b=0.8, When b=0, the curve is a circle.
// file name: egg_curve_1b_E.c
#include< stdio.h>
#include< math.h>
void main(void)
{
double x,y,a,b,pi;// pi is the 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=1.0;
b=.7;
printf("a=%f\n\n",a);
// Setting of the other parameters
dt=pi/4000;// plotting interval of intermediate variable t
i=0;
// execution of calculation
for(t=-pi;t<=pi;t=t+dt)
{
i++;
x=a/2-b/4+(a/2)*cos(t)+(b/4)*cos(t)*cos(t);
y=(a/2-b/4+(b/4)*cos(t))*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