//  Calculation Program for displaying six egg curves. (egg shaped curve V), 05 (Thurs.) Nov., 2009



// file name: egg5b2.c



#include< stdio.h>

#include< math.h>



void main(void)

{

	double x,y,a,c,p,dc,cmax,pai;

	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

	pai=3.1415927;

        a=1;

	p=0.8;

	cmax=.5;

	dc=cmax/5;



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

	 

// Setting of the other parameter

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



// execution of calculation

	i=0;

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

	{

		i++;

		n=0;



		for(c=0;c<=cmax+dc/100;c=c+dc)

		{

			n++;

			x=a*cos(t);

	    	y=(c*cos(t)+(p-c))*sin(t);

			yy[n][i]=y;

			xx[i]=x;

			printf("i=%d,x=%f,y=%f\n",i,x,y);

		}

	}

	imax=i;

	nmax=n;



// 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,%f,%f,%f,%f,%f\n",xx[i],yy[1][i],yy[2][i],yy[3][i],yy[4][i],yy[5][i],yy[6][i]);

			}

		fflush(fp);

		fclose(fp);

		}

	printf("end\n");

}// the end of the program





RETURN