naca.cpp

来自「计算NACA4位翼型的程序,在E盘naca文件夹下生成翼型数据,保存为.txt格」· C++ 代码 · 共 134 行

CPP
134
字号
#include<iostream.h>
#include<math.h>
#include<stdlib.h>
#include<fstream.h>


void f0out(double x1,double y1)
{
	
	ofstream f1("e:\\naca\\up.txt",ios::app);
    
	if(!f1)
	
	{
		
		cerr<<"e:\\naca\\down.xls file not open!"<<endl;
	   
		exit(1);
	}



	f1<<x1<<'\t'<<y1<<endl;
	f1.close();
}


void f1out(double x1,double y1)
{
	
	ofstream f1("e:\\naca\\down.txt",ios::app);
    
	if(!f1)
	
	{
		
		cerr<<"e:\\naca\\af.xls file not open!"<<endl;
	   
		exit(1);
	}



	f1<<x1<<'\t'<<y1<<endl;
	f1.close();
}





void main()
{   
    cout<<"input NACA numbers,such as 0 0 12,0 0 15,0 0 18..."<<endl;
	

	//first
	//
	//
    double t,t1,t2,t34,yf;
	cin>>t1;
	                      //cout<<t1<<endl;
	//second
	//
	//
	cin>>t2;             //cout<<t2<<endl;
	
	//t-
	cin>>t34;
	t=t34/100;          //cout<<t34<<endl;


	//x-f
    double xf=t2/10;    //cout<<xf<<endl;


	//f
	double f=t1/100;   //cout<<f<<endl;

	//rt
	double rt=1.1019*pow(t,2);

    cout<<"input how many datas you want,must be integer "<<endl;
	int i1;
	cin>>i1;
	double xstep=1.0/i1;

	double x=0.0;
	do{ 
		 
		
		 double yt=t/0.2*(0.2969*sqrt(x)-0.126*x-0.3516*pow(x,2)+0.2843*pow(x,3)-0.1015*pow(x,4));
	     //cout<<x<<" "<<y<<endl; 

		 
		 
		 
		 //
		 //中弧线方程
		 if(x<xf)
		 {
			 
			  yf=f/(xf*xf)*(2*xf*x-x*x);
			  
		 //cout<<yf<<endl;
		 
		 }
		 else{
			
			 
			 yf=f/((1-xf)*(1-xf))*((1-2*xf)+2*xf*x-x*x);
		     
		 //cout<<yf<<endl;
		 
		 }
		 
		 
		 
		 f0out(x,yf+yt);
		 f1out(x,yf-yt);
		 x=x+xstep;
	  
	}
	while(x<=1+xstep);
   system("PAUSE");
   //system("date");
}



//
//取中弧线
//

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?