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

📄 longgetutadlg.cpp

📁 龙格库塔算法
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// LonggetutaDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Longgetuta.h"
#include "LonggetutaDlg.h"
#include "math.h"

#define  we              (7.292115e-5)
#define  Ae              (6378136)             //地球赤道半径M
#define  C20             (-1.08262998905e-3)     // 地球重力常数
#define  GM              (0.39860047e15)


#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()

/////////////////////////////////////////////////////////////////////////////
// CLonggetutaDlg dialog

CLonggetutaDlg::CLonggetutaDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CLonggetutaDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CLonggetutaDlg)
	m_X = 0.0;
	m_Y = 0.0;
	m_Z = 0.0;
	m_presition = 0.0;
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CLonggetutaDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CLonggetutaDlg)
	DDX_Text(pDX, IDC_EDIT1, m_X);
	DDX_Text(pDX, IDC_EDIT2, m_Y);
	DDX_Text(pDX, IDC_EDIT3, m_Z);
	DDX_Text(pDX, IDC_EDIT4, m_presition);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CLonggetutaDlg, CDialog)
	//{{AFX_MSG_MAP(CLonggetutaDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_RUN, OnRun)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CLonggetutaDlg message handlers

BOOL CLonggetutaDlg::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 CLonggetutaDlg::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 CLonggetutaDlg::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 CLonggetutaDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CLonggetutaDlg::OnRun() 
{
	// TODO: Add your control notification handler code here
	//用四阶runge—kutta法积分卫星轨道
	double   XYZ[3]={0},XYZDot[3]={0},XYZDDot[3]={0};
	int      i;
	double   j,h,k1[3]={0},k2[3]={0},k3[3]={0},k4[3]={0};
	double   r, CoorTime,NowTime;
	double   XYZ2[3]={0},XYZDot2[3]={0};
	//////////////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////
//    XYZ[0]=-11772.6621094;
//	XYZ[1]=22448.3510742;
//	XYZ[2]=2624.15625000;
//	XYZDot[0]=0.311692237854;
//	XYZDot[1]=-0.270750999451;
//	XYZDot[2]=3.55329704285;
//	XYZDDot[0]=0.000000000000;
//	XYZDDot[1]=-0.186264514923e-08;
// 	XYZDDot[2]=0.000000000000;
//	CoorTime=4500;
//  	NowTime=6300.0;
	//////////////////////////////////////////////////////////////////////////
	XYZ[0]=-10991.1962891;
	XYZ[1]=21191.6645508;
	XYZ[2]=8835.18505859;
	XYZDot[0]=0.514831542969;
	XYZDot[1]=-1.12790489197;
	XYZDot[2]=3.30268669128;
	XYZDDot[0]=-0.186264514923e-08;
	XYZDDot[1]=-0.186264514923e-08;
 	XYZDDot[2]=0.000000000000e+00;
	CoorTime=6300.0;
 	NowTime=4500.0;
	/////////////////////////////////////////////////////////////////////////
   //////////////////////////////////////////////////////////////////////////
	for (i=0;i<3;i++)
	{
		XYZ[i]*=1000;
		XYZDot[i]*=1000;
		XYZDDot[i]*=1000;

⌨️ 快捷键说明

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