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

📄 dtprodlg.cpp

📁 一个球面积,曲率半径,子午圈的C++程序,有需要的请下载
💻 CPP
字号:
// DtProDlg.cpp : implementation file
//

#include "stdafx.h"
#include "DtPro.h"
#include "DtProDlg.h"
#include"ArcDlg.h"
#include"math.h"
#include"Length.h"
#include"AreaDilog.h"

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

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
		// No message handlers
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDtProDlg dialog

CDtProDlg::CDtProDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CDtProDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDtProDlg)
	m_la = 0.0;
	m_le = 0.0;
	m_le2 = 0;
	m_longRadius = 0.0;
	m_shortRadius = 0;
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
	m_longRadius=0;
	m_shortRadius=0;
}

void CDtProDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDtProDlg)
	DDX_Text(pDX, IDC_EDIT3, m_la);
	DDX_Text(pDX, IDC_EDIT4, m_le);
	DDX_Text(pDX, IDC_EDIT5, m_le2);
	DDX_Text(pDX, IDC_EDIT1, m_longRadius);
	DDX_Text(pDX, IDC_EDIT2, m_shortRadius);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CDtProDlg, CDialog)
	//{{AFX_MSG_MAP(CDtProDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
	ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
	ON_BN_CLICKED(IDC_RADIO3, OnRadio3)
	ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
	ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
	ON_BN_CLICKED(IDC_BUTTON4, OnButton1)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDtProDlg message handlers

BOOL CDtProDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// TODO: Add extra initialization here

	
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CDtProDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CDtProDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CDtProDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CDtProDlg::OnSelchangeTab1(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	
	*pResult = 0;
}

void CDtProDlg::OnRadio1() 
{
	// TODO: Add your control notification handler code here
	m_longRadius=6378245;
	m_shortRadius=6356863.0188;
	m_la=(m_longRadius-m_shortRadius)/m_longRadius;
	m_le=(m_longRadius*m_longRadius-m_shortRadius*m_shortRadius)/pow(m_longRadius,2);
	m_le2=(m_longRadius*m_longRadius-m_shortRadius*m_shortRadius)/pow(m_shortRadius,2);

	UpdateData(FALSE);

	
}

void CDtProDlg::OnRadio2() 
{
	// TODO: Add your control notification handler code here
	m_longRadius=6378140 ;
	m_shortRadius=6356755.2882;
	m_la=(m_longRadius-m_shortRadius)/m_longRadius;
	m_le=(m_longRadius*m_longRadius-m_shortRadius*m_shortRadius)/pow(m_longRadius,2);
	m_le2=(m_longRadius*m_longRadius-m_shortRadius*m_shortRadius)/pow(m_shortRadius,2);
	
	UpdateData(FALSE);
	
}

void CDtProDlg::OnRadio3() 
{
	// TODO: Add your control notification handler code here
	m_longRadius=6378137;
	m_shortRadius=6356752.3142;
	m_la=(m_longRadius-m_shortRadius)/m_longRadius;
	m_le=(m_longRadius*m_longRadius-m_shortRadius*m_shortRadius)/pow(m_longRadius,2);
	m_le2=(m_longRadius*m_longRadius-m_shortRadius*m_shortRadius)/pow(m_shortRadius,2);
	
	UpdateData(FALSE);
	
}

void CDtProDlg::OnButton3() 
{
	// TODO: Add your control notification handler code here
	CArcDlg dlg;
	dlg.DoModal();

	double pi=3.1415926;
	double m_nLtd=((dlg.m_lLtd+dlg.m_lStd/60)/180.)*pi;
	double e=0;
	e=sqrt(m_longRadius*m_longRadius-m_shortRadius*m_shortRadius)/m_longRadius;
    
		
	if(dlg.m_nTemp==0)
	{
	double N=m_longRadius/sqrt(1-e*e*sin(m_nLtd)*sin(m_nLtd));
	CString str;
	str.Format("卯酉圈的曲率半径为%f\n",N);
	//AfxMessageBox(str);

	double M=m_longRadius*(1-e*e)/pow((1-e*e*sin(m_nLtd)*sin(m_nLtd)),1.5);
	CString str1;
	str1.Format("子午圈的曲率半径为%f\n",M);
	str=str+str1;
	AfxMessageBox(str);
		
	}


}

void CDtProDlg::OnButton2() 
{
	// TODO: Add your control notification handler code here
	CLength dlg;
	dlg.DoModal();
	double pi=3.1415926;
	double e=0;
	e=sqrt(m_longRadius*m_longRadius-m_shortRadius*m_shortRadius)/m_longRadius;	
	double n0=m_longRadius;
	double m0=m_longRadius*(1-pow(e,2));
	double m2=3/2.*pow(e,2)*m0;
	double n2=0.5*pow(e,2)*n0;
	double m4=5/4.*pow(e,2)*m2;
	double n4=3/4.*pow(e,2)*n2;
	double m6=7/6.*pow(e,2)*m4;
	double n6=5/6.*pow(e,2)*n4;
	double m8=9/8.*pow(e,2)*m6;
	double n8=7/8.*pow(e,2)*n6;

	if(dlg.temp==1)
	{
		double a0=m0+0.5*m2+3/8.*m4+5/16.*m6+35/128.*m8;
		double a2=m2/2.+m4/2.+15/32.*m6+7/16*m8;
		double a4=m4/8.+3/16.*m6+7/32.*m8;
		double a6=m6/32+m8/16;
		double a8=m8/128;
		double B1=(dlg.m_xDg+dlg.m_xSd/60.)/180.*pi;
		double X1=a0*B1-a2/2.*sin(2*B1)+a4/4.*sin(4*B1)-a6/6.*sin(6*B1)+a8/8*sin(8*B1);
		double B2=(dlg.m_xDg1+dlg.m_xSd1/60.)/180.*pi;
		double X2=a0*B2-a2/2.*sin(2*B2)+a4/4.*sin(4*B2)-a6/6.*sin(6*B2)+a8/8*sin(8*B2);

		double m_result_x=X2-X1;
		double B=0;
		//AfxMessageBox("IJ");
		if(m_result_x<0.0)
		{
			m_result_x=0-m_result_x;
		}

		if(dlg.m_bUsed==0)
		{
			B=(dlg.m_xDg+dlg.m_xSd/60)/180*pi;
			
		}
		else
		{
			B=(dlg.m_xDg1+dlg.m_xSd1/60)/180*pi;
		}
			double L=(dlg.m_yDg-dlg.m_yDg1+(dlg.m_ySd-dlg.m_ySd1)/60.)/180.*pi;
		
			double N=m_longRadius/sqrt(1-pow(e,2)*pow(sin(B),2));
			double m_result_y=N*cos(B)*L;
			if(m_result_y<0)
			{
				m_result_y=0-m_result_y;
			}
			

		CString str="";
		str.Format("子午圈的弧长为%f\n",m_result_x);
		CString str1;
		str1.Format("平行圈的弧长为%f\n",m_result_y);
		
		str=str+str1;
		AfxMessageBox(str,MB_YESNO);		

		
	}
	
}

void CDtProDlg::OnButton1() 
{
	// TODO: Add your control notification handler code here
	CAreaDilog dlg;
	if(dlg.DoModal()==IDOK)
	{
			double b=m_shortRadius;
			double pi=3.1415926;
			double e=sqrt(m_longRadius*m_longRadius-m_shortRadius*m_shortRadius)/m_longRadius;
			double Area=0;
			double L1=(dlg.m_lLatD1+dlg.m_lLatS1/60.)/180.*pi;
			double L2=(dlg.m_lLatd2+dlg.m_lLats2/60.)/180.*pi;
			double B1=(dlg.m_bLatD1+dlg.m_bLatS1/60.)/180.*pi;
			double B2=(dlg.m_bLatd2+dlg.m_bLats2/60.)/180.*pi;
			double p2=(L2-L1)*(sin(B2)+2/3.*pow(e,2)*pow(sin(B2),3)+3/5.*pow(e,4)*pow(sin(B2),5)+4/7.*pow(e,6)*pow(sin(B2),7));
			double p1=(L2-L1)*(sin(B1)+2/3.*pow(e,2)*pow(sin(B1),3)+3/5.*pow(e,4)*pow(sin(B1),5)+4/7.*pow(e,6)*pow(sin(B1),7));
			Area=(p2-p1)*pow(b,2);
			if(Area<0){Area=0-Area;	}
			CString  str;
			str.Format("椭球梯形面积为%f\n",Area);
			AfxMessageBox(str,MB_YESNO);
	}
	
		
}

⌨️ 快捷键说明

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