// Calculation Program for displaying a single circle, 2 July, 2008



// Equation of the curve: b*b*x*x+c*c*y*y=a*a. a, b and c are arbitrary real numbers.

// file name: cercle.c



#include< stdio.h>

#include< math.h>



void main(void)

{

	double x,y,a,b,c;

	int i,imax,j,m;

	double xmin,xmax,dx;

	double xx[10001],yy[10001];



	FILE *fp;



// Setting of the constants

	a=1;

	b=1;

	c=1;



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



// Setting of the other parameters

// xmin and xmax are the minimum and maximum points of the curve on the x-axis

	xmin=-sqrt(a*a/(b*b));

	xmax=sqrt(a*a/(b*b));

	dx=(xmax-xmin)/4000;// plotting interval of x



// execution of calculation

	i=0;

	for(x=xmin;x<=xmax;x=x+dx)

		{

		i++;



		xx[i]=x;



		y=sqrt((a*a-b*b*x*x)/(c*c));

		yy[i]=y;

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

		}

	imax=i;

	j=0;



	for(i=imax+1;i<=2*imax;i++)

		{

		j++;

		m=imax-j;



		xx[i]=xx[m];

		x=xx[i];

		yy[i]=-sqrt((a*a-b*b*x*x)/(c*c));

		}



// writing the calculated coordinates data of the curve into a textfile

	fp=fopen("circle.txt","w");

	if(fp==NULL)

		{

		printf("FILE OPEN ERROR\n");

		}

	else

		{

		for(i=1;i<=2*imax-1;i++)

			{

			fprintf(fp,"%f,%f\n",xx[i],yy[i]);

			}

		fflush(fp);

		fclose(fp);

		}

	printf("end\n");

}// the end of the program





RETURN