//  Calculation Program for displaying a single egg curve 3 (Suugaku-Dokusyuu-Juku's), 18(Fri.) Sep, 2009



// file name: egg_shaped_curve_3.c



// the recommended values : a = 1.35, b = 1.15, c = 0.5



#include< stdio.h>

#include< math.h>



void main(void)

{

	double x,y,r,a,b,c,pai;

	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

	pai=3.1415927;

        a=1.35;

        b=1.15;

	c=0.5;



	printf("a=%f\n\n",a);

	 

// Setting of the other parameter

	dt=pai/1000;// the plotting interval of the phase angle



// execution of calculation

	i=0;

	for(t=0;t<=2*pai+0.001;t=t+dt)

		{

		i++;



                r=(a+c+(c-a)*cos(t))/2;

		x=b*cos(t)/2+r*cos(t);

		y=r*sin(t);



		yy[i]=y;

		xx[i]=x;



		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