-
大小: 861KB文件類型: .rar金幣: 2下載: 0 次發(fā)布日期: 2021-06-19
- 語言: 其他
- 標(biāo)簽: 坐標(biāo)轉(zhuǎn)換??
資源簡(jiǎn)介
GPS單點(diǎn)定位程序設(shè)計(jì)大地坐標(biāo)和空間直角坐標(biāo)之間的相互轉(zhuǎn)換

代碼片段和文件信息
#include
#include
using?namespace?std;
#define?M_PI?3.1415926
typedef?struct?tagCRDCARTESIAN
{
double?x;
double?y;
double?z;
}CRDCARTESIAN;
typedef?CRDCARTESIAN?*PCRDCARTESIAN;
typedef?struct?tagCRDGEODETIC
{
double?longitude;
double?latitude;
double?height;
}CRDGEODETIC;
typedef?CRDGEODETIC?*PCRDGEODETIC;
void?DMS_RAD(double?DMSdouble?*Rad)
{
int?DegMin;
double?Sec;
Deg=(int)DMS;
Min=(int)((DMS-Deg)*100);
Sec=((DMS-Deg)*100-Min)*100;
*Rad=(Deg+Min/60.0+Sec/3600.0)/180.0*M_PI;
return;
}
void?RAD_DMS(double?Raddouble?*DMS)
{
int?DegMin;
double?Sec;
double?ARAM;
AR=Rad;
if?(Rad<0)
AR=-Rad;
AR=AR+1.0e-10;
AR=AR*180.0/M_PI;
Deg=(int)AR;
AM=(AR-Deg)*60.0;
Min=(int)AM;
Sec=(AM-Min)*60;
*DMS=Deg+Min/100.0+Sec/10000.0;
if(Rad<0)
*DMS=-*DMS;
return;
}
bool?CRDCARTESIANtoCRDGEODETIC(PCRDCARTESIAN?pccPCRDGEODETIC?pcgdouble?dSemiMajorAxisdouble?dFlattening)
{
double?B0RN;
double?B_L_;
double?X=pcc->x;
double?Y=pcc->y;
double?Z=pcc->z;
R=sqrt(X*X+Y*Y);
B0=atan2(ZR);
while?(1)
{
N=dSemiMajorAxis/sqrt(1.0-dFlattening*(2-dFlattening)*sin(B0)*sin(B0));
B_=atan2(Z+N*dFlattening*(2-dFlattening)*sin(B0)R);
if(fabs(B_-B0)<1.0e-10)
break;
B0=B_;
}
L_=atan2(YX);
pcg->height=R/cos(B_)-N;
RAD_DMS(B_&pcg->latitude);
RAD_DMS(L_&pcg->longitude);
return?true;
}
bool?CRDGEODETICtoCRDCARTESEAN(PCRDGEODETIC?pcgPCRDCARTESIAN?pccdouble?dSemiMajorAxisdouble?dFlattening)
{
double?N;
double?B_L_;
double?B=pcg->latitude;
double?L=pcg->longitude;
double?H=pcg->height;
DMS_RAD(B&B_);
DMS_RAD(L&L_);
N=dSemiMajorAxis/sqrt(1.0-dFlattening*(2-dFlattening)*sin(B_)*sin(B_));
pcc->x=(N+H)*cos(B_)*cos(L_);
pcc->y=(N+H)*cos(B_)*sin(L_);
pcc->z=(N*(1.0-dFlattening*(2-dFlattening))+H)*sin(B_);
return?true;
}
void?main()
{
PCRDCARTESIAN??pcc=new?CRDCARTESIAN;
PCRDGEODETIC??pcg=new?CRDGEODETIC;
//B=30.31.40.23????L=114.21.20.51?h=41
double?rad;
rad=(30*3600+31*60+40.23)/3600;
pcg->latitude=rad;
rad=(114*3600+21*60+20.51)/3600;
pcg->height=41;
pcg->longitude=rad;
double?dSemiMajorAxis=6378137;
double?dFlatning=1/298.257223563;
cout<
cout<<“轉(zhuǎn)換前已知的大地坐標(biāo):“< cout<<“H(高度)=“<height<<“???“<<“L(經(jīng)度)=“<longitude<<“???“<<“B(緯度)=“<latitude<
CRDGEODETICtoCRDCARTESEAN(pcg?pcc?dSemiMajorAxisdFlatning);
cout< cout<<“轉(zhuǎn)換后的空間直角坐標(biāo):“;
cout<<“x=“<x<<“???“<<“y=“<y<<“???“<<“z=“<z<<“???“<
CRDCARTESIANtoCRDGEODETIC(pccpcgdSemiMajorAxisdFlatning);
cout< cout<<“由轉(zhuǎn)換后的空間直角坐標(biāo)xyz還原成大地坐標(biāo):“< cout<<“H(高度)=“<height<<“???“<<“L(經(jīng)度)=“<longitude<<“???“<<“B(緯度)=“<latitude< cout<
}
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件???????2892??2011-01-04?17:19??坐標(biāo)轉(zhuǎn)換\2.cpp
?????文件???????4584??2011-01-04?16:43??坐標(biāo)轉(zhuǎn)換\2.dsp
?????文件????????527??2011-01-04?16:43??坐標(biāo)轉(zhuǎn)換\2.dsw
?????文件??????41984??2011-01-09?20:10??坐標(biāo)轉(zhuǎn)換\2.ncb
?????文件????????864??2011-01-04?19:49??坐標(biāo)轉(zhuǎn)換\2.plg
?????文件?????528459??2011-01-04?19:49??坐標(biāo)轉(zhuǎn)換\Debug\2.exe
?????文件?????786348??2011-01-04?19:49??坐標(biāo)轉(zhuǎn)換\Debug\2.ilk
?????文件?????158300??2011-01-04?17:19??坐標(biāo)轉(zhuǎn)換\Debug\2.obj
?????文件????2011076??2011-01-04?16:55??坐標(biāo)轉(zhuǎn)換\Debug\2.pch
?????文件????1082368??2011-01-04?17:19??坐標(biāo)轉(zhuǎn)換\Debug\2.pdb
?????文件??????82944??2011-01-04?19:49??坐標(biāo)轉(zhuǎn)換\Debug\vc60.idb
?????文件?????110592??2011-01-04?17:19??坐標(biāo)轉(zhuǎn)換\Debug\vc60.pdb
?????文件??????53760??2011-01-09?20:10??坐標(biāo)轉(zhuǎn)換\2.opt
?????目錄??????????0??2011-01-09?20:09??坐標(biāo)轉(zhuǎn)換\Debug
?????目錄??????????0??2011-01-09?20:09??坐標(biāo)轉(zhuǎn)換
-----------?---------??----------?-----??----
??????????????4864698????????????????????15
- 上一篇:匯編語言課程設(shè)計(jì)案例精編源代碼
- 下一篇:typec封裝尺寸圖
評(píng)論
共有 條評(píng)論