窗体卫星位置解算系统代码.docx
《窗体卫星位置解算系统代码.docx》由会员分享,可在线阅读,更多相关《窗体卫星位置解算系统代码.docx(14页珍藏版)》请在冰豆网上搜索。
窗体卫星位置解算系统代码
设计模版
//实验二卫星位置计算Dlg.h:
headerfile
//
#if!
defined(AFX_DLG_H__C35780D1_78FB_4245_A626_FA02EBEB8030__INCLUDED_)
#defineAFX_DLG_H__C35780D1_78FB_4245_A626_FA02EBEB8030__INCLUDED_
#if_MSC_VER>1000
#pragmaonce
#endif//_MSC_VER>1000
/////////////////////////////////////////////////////////////////////////////
//CMyDlgdialog
classCMyDlg:
publicCDialog
{
//Construction
public:
doubleZk;
doubleYk;
doubleXk;
doubleypk;
doublexpk;
doublecorr_i;
doublecorr_r;
doublecorr_u;
doublerk;
doubleuk;
doublephik;
doubleomegak;
doubleik;
doubletak;
doubleek;
doublemk;
doubletk;
doublen;
doubleA;
doublen0;
doublebigomegadot;
doubleearthrate;
doublet;
doubletA;
CMyDlg(CWnd*pParent=NULL);//standardconstructor
//DialogData
//{{AFX_DATA(CMyDlg)
enum{IDD=IDD_MY_DIALOG};
CEditm_Zk;
CEditm_Yk;
CEditm_Xk;
CEditm_wk;
CEditm_yk;
CEditm_xk;
CEditm_ik;
CEditm_rk;
CEditm_uk;
CEditm_i;
CEditm_r;
CEditm_u;
CEditm_Ak;
CEditm_Vk;
CEditm_t;
CEditm_Ek;
CEditm_Mk;
CEditm_tA;
CEditm_tK;
CEditm_n0;
doublem_toe;
doublem_roota;
doublem_e;
doublem_i0;
doublem_bigomega0;
doublem_smallomega;
doublem_m0;
doublem_idot;
doublem_delta_n;
doublem_cuc;
doublem_cus;
doublem_crc;
doublem_crs;
doublem_cic;
doublem_cis;
//}}AFX_DATA
//ClassWizardgeneratedvirtualfunctionoverrides
//{{AFX_VIRTUAL(CMyDlg)
protected:
virtualvoidDoDataExchange(CDataExchange*pDX);//DDX/DDVsupport
//}}AFX_VIRTUAL
//Implementation
protected:
HICONm_hIcon;
//Generatedmessagemapfunctions
//{{AFX_MSG(CMyDlg)
virtualBOOLOnInitDialog();
afx_msgvoidOnSysCommand(UINTnID,LPARAMlParam);
afx_msgvoidOnPaint();
afx_msgHCURSOROnQueryDragIcon();
afx_msgvoidOnQuit();
afx_msgvoidOnjisuan();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
//MicrosoftVisualC++willinsertadditionaldeclarationsimmediatelybeforethepreviousline.
#endif//!
defined(AFX_DLG_H__C35780D1_78FB_4245_A626_FA02EBEB8030__INCLUDED_)
//实验二卫星位置计算Dlg.cpp:
implementationfile
//
#include"stdafx.h"
#include"实验二卫星位置计算.h"
#include"实验二卫星位置计算Dlg.h"
#include
#ifdef_DEBUG
#definenewDEBUG_NEW
#undefTHIS_FILE
staticcharTHIS_FILE[]=__FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
//CAboutDlgdialogusedforAppAbout
classCAboutDlg:
publicCDialog
{
public:
CAboutDlg();
//DialogData
//{{AFX_DATA(CAboutDlg)
enum{IDD=IDD_ABOUTBOX};
//}}AFX_DATA
//ClassWizardgeneratedvirtualfunctionoverrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtualvoidDoDataExchange(CDataExchange*pDX);//DDX/DDVsupport
//}}AFX_VIRTUAL
//Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg:
:
CAboutDlg():
CDialog(CAboutDlg:
:
IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
voidCAboutDlg:
:
DoDataExchange(CDataExchange*pDX)
{
CDialog:
:
DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg,CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
//Nomessagehandlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//CMyDlgdialog
CMyDlg:
:
CMyDlg(CWnd*pParent/*=NULL*/)
:
CDialog(CMyDlg:
:
IDD,pParent)
{
//{{AFX_DATA_INIT(CMyDlg)
m_toe=0.7220305700000E+04f;
m_roota=0.515365263176E+04f;
m_e=0.678421219345E-02f;
m_i0=0.958512160302E+00f;
m_bigomega0=-0.137835982556E+01f;
m_smallomega=-0.258419417299E+01f;
m_m0=-0.290282040486E+00f;
m_idot=-0.253939149013E-09f;
m_delta_n=0.451411660250E-08f;
m_cuc=0.189989805222E-06f;
m_cus=0.912137329578E-05f;
m_crc=0.201875000000E+03f;
m_crs=0.406250000000E+01f;
m_cic=0.130385160446E-07f;
m_cis=0.949949026108E-07f;
//}}AFX_DATA_INIT
//NotethatLoadIcondoesnotrequireasubsequentDestroyIconinWin32
m_hIcon=AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
//BOOL?
?
UpdateData(BOOL?
?
bSaveAndValidate=TRUE);
voidCMyDlg:
:
DoDataExchange(CDataExchange*pDX)
{
CDialog:
:
DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMyDlg)
DDX_Control(pDX,IDC_EDIT39,m_Zk);
DDX_Control(pDX,IDC_EDIT38,m_Yk);
DDX_Control(pDX,IDC_EDIT37,m_Xk);
DDX_Control(pDX,IDC_EDIT36,m_wk);
DDX_Control(pDX,IDC_EDIT35,m_yk);
DDX_Control(pDX,IDC_EDIT34,m_xk);
DDX_Control(pDX,IDC_EDIT12,m_ik);
DDX_Control(pDX,IDC_EDIT10,m_rk);
DDX_Control(pDX,IDC_EDIT13,m_uk);
DDX_Control(pDX,IDC_EDIT33,m_i);
DDX_Control(pDX,IDC_EDIT32,m_r);
DDX_Control(pDX,IDC_EDIT31,m_u);
DDX_Control(pDX,IDC_EDIT30,m_Ak);
DDX_Control(pDX,IDC_EDIT40,m_Vk);
DDX_Control(pDX,IDC_EDIT41,m_t);
DDX_Control(pDX,IDC_EDIT29,m_Ek);
DDX_Control(pDX,IDC_EDIT28,m_Mk);
DDX_Control(pDX,IDC_EDIT27,m_tA);
DDX_Control(pDX,IDC_EDIT21,m_tK);
DDX_Control(pDX,IDC_EDIT20,m_n0);
DDX_Text(pDX,IDC_EDIT1,m_toe);
DDX_Text(pDX,IDC_EDIT2,m_roota);
DDX_Text(pDX,IDC_EDIT3,m_e);
DDX_Text(pDX,IDC_EDIT4,m_i0);
DDX_Text(pDX,IDC_EDIT5,m_bigomega0);
DDX_Text(pDX,IDC_EDIT6,m_smallomega);
DDX_Text(pDX,IDC_EDIT7,m_m0);
DDX_Text(pDX,IDC_EDIT8,m_idot);
DDX_Text(pDX,IDC_EDIT9,m_delta_n);
DDX_Text(pDX,IDC_EDIT14,m_cuc);
DDX_Text(pDX,IDC_EDIT15,m_cus);
DDX_Text(pDX,IDC_EDIT16,m_crc);
DDX_Text(pDX,IDC_EDIT17,m_crs);
DDX_Text(pDX,IDC_EDIT18,m_cic);
DDX_Text(pDX,IDC_EDIT19,m_cis);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMyDlg,CDialog)
//{{AFX_MSG_MAP(CMyDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDCANCEL,OnQuit)
ON_BN_CLICKED(IDC_BUTTON1,Onjisuan)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//CMyDlgmessagehandlers
BOOLCMyDlg:
:
OnInitDialog()
{
CDialog:
:
OnInitDialog();
//Add"About..."menuitemtosystemmenu.
//IDM_ABOUTBOXmustbeinthesystemcommandrange.
ASSERT((IDM_ABOUTBOX&0xFFF0)==IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX<0xF000);
CMenu*pSysMenu=GetSystemMenu(FALSE);
if(pSysMenu!
=NULL)
{
CStringstrAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if(!
strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING,IDM_ABOUTBOX,strAboutMenu);
}
}
//Settheiconforthisdialog.Theframeworkdoesthisautomatically
//whentheapplication'smainwindowisnotadialog
SetIcon(m_hIcon,TRUE);//Setbigicon
SetIcon(m_hIcon,FALSE);//Setsmallicon
//TODO:
Addextrainitializationhere
returnTRUE;//returnTRUEunlessyousetthefocustoacontrol
}
voidCMyDlg:
:
OnSysCommand(UINTnID,LPARAMlParam)
{
if((nID&0xFFF0)==IDM_ABOUTBOX)
{
CAboutDlgdlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog:
:
OnSysCommand(nID,lParam);
}
}
//Ifyouaddaminimizebuttontoyourdialog,youwillneedthecodebelow
//todrawtheicon.ForMFCapplicationsusingthedocument/viewmodel,
//thisisautomaticallydoneforyoubytheframework.
voidCMyDlg:
:
OnPaint()
{
if(IsIconic())
{
CPaintDCdc(this);//devicecontextforpainting
SendMessage(WM_ICONERASEBKGND,(WPARAM)dc.GetSafeHdc(),0);
//Centericoninclientrectangle
intcxIcon=GetSystemMetrics(SM_CXICON);
intcyIcon=GetSystemMetrics(SM_CYICON);
CRectrect;
GetClientRect(&rect);
intx=(rect.Width()-cxIcon+1)/2;
inty=(rect.Height()-cyIcon+1)/2;
//Drawtheicon
dc.DrawIcon(x,y,m_hIcon);
}
else
{
CDialog:
:
OnPaint();
}
}
//Thesystemcallsthistoobtainthecursortodisplaywhiletheuserdrags
//theminimizedwindow.
HCURSORCMyDlg:
:
OnQueryDragIcon()
{
return(HCURSOR)m_hIcon;
}
voidCMyDlg:
:
OnQuit()
{
//TODO:
Addyourcontrolnotificationhandlercodehere
CMyDlg:
:
OnCancel();
}
voidCMyDlg:
:
Onjisuan()
{
//TODO:
Addyourcontrolnotificationhandlercodehere
earthrate=7.2921151467e-5;
A=m_roota*m_roota;
n0=sqrt(3.986005e14/(A*A*A));
t=0.720000000000E+04;
tA=m_toe;
tk=t-m_toe;
n=n0+m_delta_n;
mk=m_m0+n*tk;
ek=mk;
for(inti=0;i<10;i++){ek=mk+m_e*sin(ek);}
tak=atan2(sqrt(1.0-m_e*m_e)*sin(ek),cos(ek)-m_e);
phik=tak+m_smallomega;
corr_u=m_cus*sin(2.0*phik)+m_cuc*cos(2.0*phik);
corr_r=m_crs*sin(2.0*phik)+m_crc*cos(2.0*phik);
corr_i=m_cis*sin(2.0*phik)+m_cic*cos(2.0*phik);
uk=phik+corr_u;
rk=A*(1.0-m_e*cos(ek))+corr_r;
xpk=rk*cos(uk);
ypk=rk*sin(uk);
omegak=m_bigomega0+(bigomegadot-earthrate)*tk-earthrate*m_toe;
Xk=xpk*cos(omegak)-ypk*sin(omegak)*cos(ik);
Yk=xpk*sin(omegak)+ypk*cos(omegak)*cos(ik);
Zk=ypk*sin(ik);
CStringsz1,sz2,sz3,sz4,sz5,sz6,sz7,sz8,sz9,sz10,sz11,sz12,sz13,sz14,sz15,sz16,sz17,sz18,sz19,sz20;
sz1.Format("%1f",n0);
m_n0.SetWindowText(sz1);
sz1.ReleaseBuffer(0);
sz2.Format("%1f",tk);
m_tK.SetWindowText(sz2);
sz2.ReleaseBuffer(0);
sz3.Format("%1f",tA);
m_tA.SetWindowText(sz3);
sz3.ReleaseBuffer(0);
sz4.Format("%1f",t);
m_t.SetWindowText(sz4);
sz4.ReleaseBuffer(0);
sz5.Format("%1f",mk);
m_Mk.SetWindowText(sz5);
sz5.ReleaseBuffer(0);
sz6.Format("%1f",ek);
m_Ek.SetWindowText(sz6);
sz6.ReleaseBuffer(0);
sz7.Format("%1f",tak);
m_Vk.SetWindowText(sz7);
sz7.ReleaseBuffer(0);
sz8.Format("%1f",phik);
m_Ak.SetWindowText(sz8);
sz8.ReleaseBuffer(0);
sz9.Format("%1f",corr_u);
m_u.SetWindowText(sz9);
sz9.ReleaseBuffer(0);
sz10.Format("%1f",corr_r);
m_r.SetWindowText(sz10);
sz10.ReleaseBuffer(0);
sz11.Format("%1f",corr_i);
m_i.SetWindowText(sz11);
sz11.ReleaseBuffer(0);
sz12.Format("%1f",uk);
m_uk.SetWindowText(sz12);
sz12.ReleaseBuffer(0);
sz13.Format("%1f",rk);
m_rk.SetWindowText(sz13);
sz13.ReleaseBuffer(0);