// Calculation Program for displaying five egg curves etc. (by Mr. Yasuyuki ASAI [Suugaku-Dokusyuu-Juku's]), 30(Thurs.) July, 2009



// in the case that a=1, c=2.00~3.25 // a circle for c=1, a crecent for 0 < c <1, a round fan for 1 < c < 2, and an egg for c > 2



// file name: egg_shaped_curve_SUUDOKU_a.c



#include< stdio.h>

#include< math.h>



void main(void)

{

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

	double t,dt;

	int i,imax,n,nmax;

	double xx[10][2001],yy[10][2001];// Take care of the upper limit of storage memory capacitance.



	FILE *fp;



// Setting of the constants

	pai=3.1415927;

        a=1;

	cmin=2;// in the case that a=1, c=2.00~3.25 // a circle for c=1, a crecent for 0 < c <1, a round fan for 1 < c < 2, and an egg for c > 2

	cmax=3.25;

	dc=(cmax-cmin)/5;



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

	 

// Setting of the other parameters

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



// execution of calculation

	i=0;

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

	{

		i++;

		n=0;



		for(c=cmin;c<=cmax+0.001;c=c+dc)

		{

			n++;

			x=a*((c-2)*cos(t)+c+2)*(cos(t)+1)/4;

			y=a*sin(t);

			yy[n][i]=y;

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

			}

		fflush(fp);

		fclose(fp);

		}

	printf("end\n");

}

// the end of the program





RETURN