// [このプログラムの目的]1個の凸形歪円曲線を描くこと,2008年6月29日(日)
// 凸形歪円曲線の方程式:exp(b*b*x*x)+exp(c*c*y*y)=2*exp(a*a). なお、a, ,b, c は任意の実数。
// file name: distorted_circle_convex.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;
//  定数設定
	a=10;
	b=2;
	c=1;
	printf("a=%f\n\n",a);
//  他のパラメータ設定
	// xmin と xmax は凸形歪円曲線がx軸を切る(すなわち、方程式が y=0 を満たす)2点のx座標。
	xmin=-sqrt(log(2*exp(a*a)-1)/(b*b));
	xmax=sqrt(log(2*exp(a*a)-1)/(b*b));
	dx=(xmax-xmin)/4000;// x のプロット間隔
//  計算実行
	i=0;
	for(x=xmin+dx;x< xmax;x=x+dx)
		{
		i++;
		xx[i]=x;
		y=sqrt(log(2*exp(a*a)-exp(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-1;i++)
		{
		j++;
		m=imax-j;
		xx[i]=xx[m];
		x=xx[i];
		yy[i]=-sqrt(log(2*exp(a*a)-exp(b*b*x*x))/(c*c));
		}
	xx[2*imax]=xx[1];
	x=xx[2*imax];
	y=sqrt(log(2*exp(a*a)-exp(b*b*x*x))/(c*c));
	yy[2*imax]=y;
// 計算データ(凸形歪円曲線の(x,y)座標)をテキストファイル(distorted_circle.txt)に書き込む
	fp=fopen("distorted_circle.txt","w");
	if(fp==NULL)
		{
		printf("FILE OPEN ERROR\n");
		}
	else
		{
		for(i=1;i<=2*imax;i++)
			{
			fprintf(fp,"%f,%f\n",xx[i],yy[i]);
			}
		fflush(fp);
		fclose(fp);
		}
	printf("end\n");
}// the end of the program
戻る