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

📄 angle.cpp

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

#include "stdafx.h"
#include "celiang.h"
#include "angle.h"

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

/////////////////////////////////////////////////////////////////////////////
// angle dialog


angle::angle(CWnd* pParent /*=NULL*/)
	: CDialog(angle::IDD, pParent)
{
	//{{AFX_DATA_INIT(angle)
	m_x0 = 0.0;
	m_x1 = 0.0;
	m_x2 = 0.0;
	m_y0 = 0.0;
	m_y1 = 0.0;
	m_y2 = 0.0;
	m_af = 0.0;
	m_s = 0.0;
	//}}AFX_DATA_INIT
}


void angle::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(angle)
	DDX_Control(pDX, IDC_x0_EDIT, m_x10);
	DDX_Text(pDX, IDC_x0_EDIT, m_x0);
	DDX_Text(pDX, IDC_x1_EDIT, m_x1);
	DDX_Text(pDX, IDC_x2_EDIT, m_x2);
	DDX_Text(pDX, IDC_y0_EDIT, m_y0);
	DDX_Text(pDX, IDC_y1_EDIT, m_y1);
	DDX_Text(pDX, IDC_y2_EDIT, m_y2);
	DDX_Text(pDX, IDC_af_EDIT, m_af);
	DDX_Text(pDX, IDC_EDIT1, m_s);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(angle, CDialog)
	//{{AFX_MSG_MAP(angle)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// angle message handlers
#define PI 3.14159265357929
#include<math.h>
#include"angle.h"

class angle::Point
{
    public:
       double x,y,z;
     Point(double a,double b,double c);
		 ~Point(){;}
};
angle::Point::Point(double a,double b,double c)
{
	x=a;
	y=b;
	z=c;
}

double angle::dire(double x1,double y1,double x2,double y2)
{ 
	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);}
	else {
		 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!\n");
		       return -10.0;}
	}
}
double angle::ang360(double j)
	{  
		double d;
		d=j*180/PI;
		return d;
	
	}
 
double angle::disp360(  double j)
	{  //用度制表示弧度
		  double d;
		d=j*180.0/PI;
		return d;
	
	}
double angle::fm_d(  double x)
{
	int t(0);
	  double x4;
	  double x3,x5;
	  if(x<0)
	  {t=2;
	  x=-x;
	  }
	  double x1=floor(x*100.0);
      double x2=x*100.0-x1;
	 x3=x2/36.0;
	 x4=floor((x*100.0-x2)/100.0);
    x5=(x*100-x2)/100.0-x4;
    x5=x5*10.0/6.0;
	//
	if(t==0) return(floor(x)+x3+x5);
	else return-(floor(x)+x3+x5);
}
double angle::d_fm(  double x)
{ //用度分秒表示dou
	  double x4;
	  double x3,x5;
	  int b(0);
	  if(x<0.0){x=-x;b=2;}
	  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.0;if(x5<0) x5=-x5;
	 if(x5<0.00001){
	x4-=60.0;

	x3+=1;
	}
    x5=x3-60.0;if(x5<0) x5=-x5;
   
	 if(x5<0.00001){
	x3-=60.0;
	x1+=1.0;
	}
     if(b==0) return x1+x3/100.0+x4/10000.0; 
	else return -(x1+x3/100.0+x4/10000.0);
  } 

double angle::h_d(  double x)
{
     double y=disp360(x);
   
ss:   if(y>=360.0) {
	   y-=360.0;
       goto ss;
   }
  return d_fm(y);

}
double angle::d_h(  double x)
{
	  double y=fm_d(x);
    return y*PI/180.0;
}
void angle::OnButton1() 
{
	// TODO: Add your control notification handler code here
  UpdateData(true);
   int ccc(0);
  Point p1(m_x0,m_y0,0),p2(m_x1,m_y1,0.0),p3(m_x2,m_y2,0);
	double angle=dire(p1.x,p1.y,p2.x,p2.y);
   double angle1=dire(p1.x,p1.y,p3.x,p3.y);
	if(angle==-10.0) goto r;
	angle=angle1-angle;
    if(angle<0) angle+=2*PI;
	angle=h_d(angle);
    m_af=angle;
 if(fabs(m_af)<0.00000001) m_af=0.0;
 if(m_af<0){ccc=3;m_af=-m_af;}	
 if(m_af*100000000-floor(m_af*100000000)>0.5) m_af=(floor(m_af*100000000)+1)/100000000.0;
	else m_af=floor(m_af*100000000)/100000000.0;
if(ccc==3) m_af=-m_af;
m_s=sqrt((m_x0-m_x2)*(m_x0-m_x2)+(m_y0-m_y2)*(m_y0-m_y2));
r:  UpdateData(false); 
	
}

void angle::OnCancel() 
{
	// TODO: Add extra cleanup here
	
	CDialog::OnCancel();
}

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

⌨️ 快捷键说明

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