// [このプログラムの目的]
// 1個の スペード曲線を、媒介変数を用いて計算して描くこと
// 2010年3月10日(火)
// file spade_a.c
#include< stdio.h>
#include< math.h>
void main(void)
{
	double x1,x2,x,y1,y2,y,a,b,c,d,k,p,q,pi;
        // pi は円周率
	double t,dt;// P点での局所的位相角とその変分
	double tmax;// P点での局所的位相角の最大値
	double xx[10001],yy[10001];// メモリ容量に注意
	int i,imax;
	FILE *fp;
//  定数設定
	a=0.0;
	b=1.0;
	c=1.19;
	d=1.5;
	k=0.115;
	p=2.0;
	q=0.58;
	
	pi=3.1415927;
	 
//  他のパラメータ設定
	tmax=4.0*pi;
	dt=2*tmax/4000;// t のプロット間隔
//  計算実行
	i=0;
	for(t=-tmax;t<=tmax;t=t+dt)
		{
		i++;
x1=a*((1.-exp(-p*t*t))/(exp(-p*t*t)+1.));
x2=c*t*t*t*exp(-q*t*t)*cos(k*t*t*t);
x=x1+x2;
y=b*((1.-exp(-p*t*t))/(exp(-p*t*t)+1.));
y=d*t*t*t*exp(-q*t*t)*sin(k*t*t*t);
y=y1+y2;
		yy[i]=-y;
		xx[i]=x;
		printf("i=%d,x=%f,y=%f\n",i,x,y);
		}
	imax=i;
// 計算データのテキストファイルへの保存
	fp=fopen("spade.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
戻る