⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zheng.cpp

📁 普通平差程序
💻 CPP
字号:
// zheng.cpp : implementation file
//

#include "stdafx.h"
#include "celiang.h"
#include "zheng.h"
#define PI 3.14159265357929
#include<math.h>


#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// zheng dialog


zheng::zheng(CWnd* pParent /*=NULL*/)
	: CDialog(zheng::IDD, pParent)
{
	//{{AFX_DATA_INIT(zheng)
	m_af1 = 0.0;
	m_x1 = 0.0;
	m_x2 = 0.0;
	m_s = 0.0;
	m_y1 = 0.0;
	m_y2 = 0.0;
	//}}AFX_DATA_INIT
}


void zheng::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(zheng)
	DDX_Text(pDX, IDC_af1_EDIT, m_af1);
	DDX_Text(pDX, IDC_x1_EDIT, m_x1);
	DDX_Text(pDX, IDC_x2_EDIT, m_x2);
	DDX_Text(pDX, IDC_xs_EDIT, m_s);
	DDX_Text(pDX, IDC_y1_EDIT, m_y1);
	DDX_Text(pDX, IDC_y2_EDIT, m_y2);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(zheng, CDialog)
	//{{AFX_MSG_MAP(zheng)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	ON_COMMAND(ID_MENUITEM32773, OnMenuitem32773)
	ON_COMMAND(ID_MENUITEM32771, OnMenuitem32771)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// zheng message handlers
	double zheng::dire(double x1,double y1,double x2,double y2)
{ //计算从点1到点2的方向(弧度制)

	double x,y;
	x=x2-x1;
	y=y2-y1;
	if(x!=0)
	{
		if(x>0 && y>=0)
		   return (atan(y/x));
	    if(x>0 && y<0)
		return (atan(y/x)+2*PI);
        if(x<0 && y<0)
			return (atan(y/x)+PI);
		if(x<0 && y>=0)
			return (atan(y/x)+PI);
	}
	if(x==0)
	{
		 if(y!=0) {if(y>0) return PI/2.0;
	        else return 3*PI/2.0;}
		 else {MessageBox("there must be a error in inputed data!");
		       return -10.0;}
	}
}
    double zheng::disp360(double j)
	{  //用度制表示弧度
		double d;
		d=j*180/PI;
		return d;
	
	}
	double zheng::fm_d(double x)
{
	double x4;
	double x3,x5;
	 double x1=floor(x*100.0);
    double x2=x*100-x1;
	 x3=x2/36.0;
	 x4=floor((x*100-x2)/100.0);
    x5=(x*100-x2)/100.0-x4;
    x5=x5*10/6.0;
	return(floor(x)+x3+x5);
}
	double zheng::d_fm(double x)
{ //用度分秒表示dou
	double x4;
	double x3,x5;
	 double x1=floor(x);
    double x2=x-x1;
	 x3=floor(60.0*x2);//this is the fen value
	 x4=(x2*60.0-x3)*60.0;//this is the miao value
    x5=x4-60;if(x5<0) x5=-x5;
	 if(x5<0.00001){
	x4-=60.0;

	x3+=1;
	}
    x5=x3-60;if(x5<0) x5=-x5;
   
	 if(x5<0.00001){
	x3-=60;
	x1+=1;
	}
return x1+x3/100+x4/10000;
	//cout<<<x1<<"."<<x3<<"#"<<x4<<"#\n";
} 
	double zheng::dist(double a,double b,double c,double d)
{
    double dist=(a-c)*(a-c)+(b-d)*(b-d);
	dist=sqrt(dist);
	return(dist);
}
	double zheng::h_d(double x)
{
   double y=disp360(x);
   return d_fm(y);
}
	double zheng::d_h(double x)
{
	double y=fm_d(x);
    return y*PI/180.0;
}

void zheng::OnButton1() 
{
	// TODO: Add your control notification handler code here
double x1,x2=0,y1,y2=0; 
// cin>>x1>>y1;
UpdateData(true);
x1=m_x1;
y1=m_y1;  
  double al;
//  cin>>al;
  al=m_af1;
  double s;
 // cin>>s;
s=m_s;
  al=d_h(al);
tt:  if(al>2*PI)
  {al-=2*PI;
  goto tt;}
tb:  if(al<0.0)
  {al+=2*PI;
  goto tb;}
 int ccc(0);
	 m_x2=x2=x1+s*cos(al);
 if(fabs(m_x2)<0.00000001) m_x2=0.0;
 if(m_x2<0){ccc=3;m_x2=-m_x2;}	
 if(m_x2*10000-floor(m_x2*10000)>0.5) m_x2=(floor(m_x2*10000)+1)/10000.0;
	else m_x2=floor(m_x2*10000)/10000.0;
if(ccc==3) m_x2=-m_x2;
 
 m_y2=y2=y1+s*sin(al);
 if(m_y2<0){ccc=6;m_y2=-m_y2;}	

	if(m_y2*10000-floor(m_y2*10000)>0.5) m_y2=(floor(m_y2*10000)+1)/10000.0;
	else m_y2=floor(m_y2*10000)/10000.0;
  if(ccc==6) m_y2=-m_y2;
if(fabs(m_y2)<0.00000001) m_y2=0.0;
UpdateData(false);
 	
}

void zheng::OnCancel() 
{
	// TODO: Add extra cleanup here
		m_af1 = 0.0;
	m_s = 0.0;
	m_x1 = 0.0;
	m_x2 = 0.0;
	m_y1 = 0.0;
	m_y2 = 0.0;
UpdateData(false);	

}

void zheng::OnOK() 
{
	// TODO: Add extra validation here
	
	CDialog::OnOK();
}

void zheng::OnMenuitem32773() 
{
	// TODO: Add your command handler code here
	MessageBox("角度的输入/输出形式,例如:123度36分24.3456秒,输入/输出形式为:123.36243456.");	
	
}

void zheng::OnMenuitem32771() 
{
	// TODO: Add your command handler code here
	OnOK();	
}

⌨️ 快捷键说明

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