高斯投影正反算c代码
高斯投影

一、高斯投影正反算 (1)采用c 语言(2)编程思想和设计框图(3)采用的基本数学模型 基本椭球参数: 椭球长半轴a 椭球扁率f椭球短半轴:(1)b a f =-椭球第一偏心率:e =椭球第二偏心率:e b'=高斯投影正算公式:此公式换算的精度为0.001m6425644223422)5861(cos sin 720)495(cos 24cos sin 2lt t B B N lt B simB N l B B N X x ''+-''+''++-''+''⋅''+=ρηηρρ5222425532233)5814185(cos 120)1(cos 6cos lt t t B N lt B N l B N y ''-++-''+''+-''+''⋅''=ηηρηρρ其中:角度都为弧度B 为点的纬度,0l L L ''=-,L 为点的经度,0L 为中央子午线经度; N 为子午圈曲率半径,1222(1sin )N a e B -=-; tan t B =;222cos e B η'=1803600ρπ''=*其中X 为子午线弧长:2402464661616sin cos ()(2)sin sin 33X a B B B a a a a a B a B ⎡⎤=--++-+⎢⎥⎣⎦02468,,,,a a a a a 为基本常量,按如下公式计算:200468242684468686883535281612815722321637816323216128m a m m m m m m a m mm a m m m m a m a ⎧=++++⎪⎪⎪=+++⎪⎪⎪=++⎨⎪⎪=+⎪⎪⎪=⎪⎩02468,,,,m m m m m 为基本常量,按如下公式计算:22222020426486379(1);;5;;268m a e m e m m e m m e m m e m =-====;高斯投影反算公式:此公式换算的精度为0.0001’’.()()()()222224324653223524222553922461904572012cos 6cos 5282468120cos f f f ff f f f ff fff f f ff f f f f f f f f f f f f t t B B y tt yM N M Nt y t t yM Ny y l t N B N B y t t t N B L l L ηηηηη=-+++--++=-+++++++=+其中:0L 为中央子午线经度。
(完整word版)高斯投影正反算 代码

L=l+L01; ///
反算就出
L B
l=L-L02;
B=Bf-(1-(b4-0.12*Z*Z)*Z*Z)*Z*Z*b2;
t=tan(B);
n2=e2*cos(B)*cos(B);
V=sqrt(1+n2);
cB2=pow(cos(B),2);
N=6399698.902-(21562.267-(108.973-0.612*cB2)*cB2)*cB2; //N=c/V;
l=L-111*3600/P // l=((m%6)*3600+n*60+h)/P;
t=tan(B);
n2=e2*cos(B)*cos(B);
V=sqrt(1+n2);
cB2=pow(cos(B),2);
N=6399698.902-(21562.267-(108.973-0.612*cB2)*cB2)*cB2; // N=c/V;
a0=32140.404-(135.3302-(0.7092-0.004*cB2)*cB2)*cB2;
a4=(0.25+0.00252*cB2)*cB2-0.04166;
a6=(0.166*cB2-0.084)*cB2;
a3=(0.3333333+0.001123*cB2)*cB2-0.1666667;
#include "stdafx.h"
#include "iostream.h"
#include "math.h"
#include "stdio.h"
#define P 206264.806247096355
C#高斯正算高斯反算高斯换带等

C#⾼斯正算⾼斯反算⾼斯换带等⾸先,你要确定椭球参数:C#代码1. a = 6378140; //西安80椭球 IGA752. e2 = 0.006694384999588;3. m0 = a * (1 - e2);4. m2 = 3.0 / 2 * e2 * m0;5. m4 = 5.0 / 4 * e2 * m2;6. m6 =7.0 / 6 * e2 * m4;7. m8 = 9.0 / 8 * e2 * m6;8. a0 = m0 + m2 / 2 + (3.0 / 8.0) * m4 + (5.0 / 16.0) * m6 + (35.0 / 128.0) * m8;9. a2 = m2 / 2 + m4 / 2 + 15.0 / 32 * m6 + 7.0 / 16 * m8;10. a4 = m4 / 8 + 3.0 / 16 * m6 + 7.0 / 32 * m8;11. a6 = m6 / 32 + m8 / 16;12. a8 = m8 / 128;13. xx = 0;14. yy = 0;15. _x = 0;16. _y = 0;17. BB = 0;18. LL = 0;下⾯才开始正题:⾼斯正算:把经纬度坐标转换为平⾯坐标C#代码1. void GaussPositive(double B, double L, double L0)2. {3. double X, t, N, h2, l, m, Bmiao, Lmiao;4. int Bdu, Bfen, Ldu, Lfen;5. Bdu = (int)B;6. Bfen = (int)(B * 100) % 100;7. Bmiao = (B - Bdu - Bfen * 0.01) * 10000.0;8. B = Bdu * PI / 180.0 + (Bfen / 60.0) * PI / 180.0 + Bmiao / 3600.0 * PI / 180.0;9. Ldu = (int)L;10. Lfen = (int)(L * 100) % 100;11. Lmiao = (L - Ldu - Lfen * 0.01) * 10000.0;12. L = Ldu * PI / 180.0 + (Lfen / 60.0) * PI / 180 + Lmiao / 3600.0 * PI / 180.0;13. l = L - L0 * PI / 180;14. X = a0 * B - Math.Sin(B) * Math.Cos(B) * ((a2 - a4 + a6) + (2 * a4 - 16.0 / 3.0 * a6) * Math.Sin(B) * Math.Sin(B) + 16.0 / 3.0 * a6 * Math.Pow(Math.Sin(B), 4)) + a8 / 8.0 * Math.Sin(8 * B);15. t = Math.Tan(B);16. h2 = e2 / (1 - e2) * Math.Cos(B) * Math.Cos(B);17. N = a / Math.Sqrt(1 - e2 * Math.Sin(B) * Math.Sin(B));18. m = Math.Cos(B) * l;19. xx = X + N * t * ((0.5 + (1.0 / 24.0 * (5 - t * t + 9 * h2 + 4 * h2 * h2) + 1.0 / 720.0 * (61 - 58 * t * t + Math.Pow(t, 4)) * m * m) * m * m) * m * m);20. yy = N * ((1 + (1.0 / 6.0 * (1 - t * t + h2) + 1.0 / 120.0 * (5 - 18 * t * t + Math.Pow(t, 4) + 14 * h2 - 58 * h2 * t * t) * m * m) * m * m) * m);21. yy = yy + 500000;22. }⾼斯反算:把平⾯坐标转换为经纬度坐标:C#代码1. void GaussNegative(double x, double y, double L0)2.3. double Bf, Vf, l, tf, hf2, Nf, Bmiao, Lmiao;4. int Bdu, Bfen, Ldu, Lfen;4. int Bdu, Bfen, Ldu, Lfen;5. y = y - 500000;6. Bf = hcfansuan(x);7. Vf = Math.Sqrt(1 + e2 / (1 - e2) * Math.Cos(Bf) * Math.Cos(Bf));8. tf = Math.Tan(Bf);9. hf2 = e2 / (1 - e2) * Math.Cos(Bf) * Math.Cos(Bf);10. Nf = a / Math.Sqrt(1 - e2 * Math.Sin(Bf) * Math.Sin(Bf));11. BB = (Bf - 0.5 * Vf * Vf * tf * (Math.Pow(y / Nf, 2) - 1.0 / 12 * (5 + 3 * tf * tf + hf2 - 9 * hf2 * tf * tf) * Math.Pow(y / Nf, 4) + 1.0 / 360 * (61 + 90 * tf * tf + 45 * tf * tf) * Math.Pow(y / Nf, 6))) * 180 / PI;12. Bdu = (int)BB;13. Bfen = (int)((BB - Bdu) * 60);14. Bmiao = ((BB - Bdu) * 60 - Bfen) * 60;15. BB = Bdu + 0.01 * Bfen + 0.0001 * Bmiao;16. l = 1.0 / Math.Cos(Bf) * (y / Nf - 1.0 / 6.0 * (1 + 2 * tf * tf + hf2) * Math.Pow(y / Nf, 3) + 1.0 / 120.0 * (5 + 28 * tf * tf + 24 * Math.Pow(tf, 4) + 6 * hf2 + 8 * hf2 * tf * tf) * Math.Pow(y / Nf, 5)) * 180.0 / PI;17. LL = L0 + l;18. Ldu = (int)LL;19. Lfen = (int)((LL - Ldu) * 60);20. Lmiao = ((LL - Ldu) * 60 - Lfen) * 60;21. LL = Ldu + 0.01 * Lfen + 0.0001 * Lmiao;⾥⾯涉及到的弧长反算:C#代码1. double hcfansuan(double pX)2. {3. double Bf0 = pX / a0;4. double Bf1, Bf2;5. Bf1 = Bf0;6. Bf2 = (pX - F(Bf1)) / a0;7. while ((Bf2 - Bf1) > 1.0E-11)8. {9. Bf1 = Bf2;10. Bf2 = (pX - F(Bf1)) / a0;11. }12. return Bf1;13. }⾼斯换带就⽐较简单了:C#代码1. void GaussZone(double x, double y, double L0, double L0new)2. {3. GaussNegative(x, y, L0);4. GaussPositive(BB, LL, L0new);5. }。
高斯投影坐标正反算编程报告

高斯投影坐标正反算编程报告1.编程思想高斯投影坐标正反算的编程需要涉及大量公式。
为了使程序更清晰,各模块的数据重用性更强,本文采用结构化编程思想。
程序由四大块组成。
大地测量家庭作业。
Cpp文件用于存储main()函数,是整个程序的入口。
尝试通过结构化编程简化main()函数。
myfunction.h和myfunction.cpp用于存放计算过程中进行角度弧度换算时所要用到的一些自定的转换函数。
正蒜。
H和zhengsuan CPP用于存储zhengsuan类。
在正算类中,声明了用于高斯投影坐标正演计算的所有变量。
成员变量的初始化和正向计算在类的构造函数中执行。
通过get函数获得相应的阳性结果。
fansuan.h和fansuan.cpp用于存放fansuan类,类似于zhengsuan类,fansuan类中声明了高斯投影坐标反算所要用到的所有变量,在类的构造函数中进行成员变量的初始化及反算计算。
通过get函数获得相应的反算结果。
2.计算模型高斯投影正算公式十、十、nn232244????sinbcosb?Lsimbcosb(5?t?9?4?)l2???224??? 4n5246??sinbcosb(61?58t?t)l720???6y??nn3223??cosb?Lcosb(1?t??)L6.3n5242225??cosb(5?18吨?14?58吨)l120???五tf2mfnf5f高斯投影反算公式B男朋友??tfy?2tf24mfn3f?5.3t2f224??2f?9? ftfy?720mfn46y61?90t2?45泰夫??yy32l??1.2t2f??f3nfcosbf6nfcosbf???y524222?5?28t?24t?6??8?fffftf5120nfcosbf?3.程序框图一开始输入b,l求定带号n,中央纬度l0,纬度差l正算按照实用公式计算x,y换算为国家统一坐标x,y输出x,y输入国家统一坐标x,y由y取定带号n,并换算出x,y求出中央经线l0反算按照实用公式计算b,ll=l0+l求出大地经度l输出b,l结束4.计算结果25.附录:程序代码/////主函数入口大地测量家庭作业。
高斯投影正算

高斯投影正、反算代码//高斯投影正、反算//////6度带宽 54年北京坐标系//高斯投影由经纬度(Unit:DD)反算大地坐标(含带号,Unit:Metres)void GaussProjCal(double longitude, double latitude, double *X, double *Y){int ProjNo=0; int ZoneWide; ////带宽double longitude1,latitude1, longitude0,latitude0, X0,Y0, xval,yval;double a,f, e2,ee, NN, T,C,A, M, iPI;iPI = 0.0174532925199433; ////3.1415926535898/180.0;ZoneWide = 6; ////6度带宽a=6378245.0; f=1.0/298.3; //54年北京坐标系参数////a=6378140.0; f=1/298.257; //80年西安坐标系参数ProjNo = (int)(longitude / ZoneWide) ;longitude0 = ProjNo * ZoneWide + ZoneWide / 2;longitude0 = longitude0 * iPI ;latitude0=0;longitude1 = longitude * iPI ; //经度转换为弧度latitude1 = latitude * iPI ; //纬度转换为弧度e2=2*f-f*f;ee=e2*(1.0-e2);NN=a/sqrt(1.0-e2*sin(latitude1)*sin(latitude1));T=tan(latitude1)*tan(latitude1);C=ee*cos(latitude1)*cos(latitude1);A=(longitude1-longitude0)*cos(latitude1);M=a*((1-e2/4-3*e2*e2/64-5*e2*e2*e2/256)*latitude1-(3*e2/8+3*e2*e2 /32+45*e2*e2*e2/1024)*sin(2*latitude1)+(15*e2*e2/256+45*e2*e2*e2/1024)*sin(4*latitude1)-(35*e2*e2*e2/30 72)*sin(6*latitude1));xval = NN*(A+(1-T+C)*A*A*A/6+(5-18*T+T*T+72*C-58*ee)*A*A*A*A*A/120);yval = M+NN*tan(latitude1)*(A*A/2+(5-T+9*C+4*C*C)*A*A*A*A/24+(61-58*T+T*T+600*C-330*ee)*A*A*A*A*A*A/720);X0 = 1000000L*(ProjNo+1)+500000L;Y0 = 0;xval = xval+X0; yval = yval+Y0;*X = xval;*Y = yval;}//高斯投影由大地坐标(Unit:Metres)反算经纬度(Unit:DD)void GaussProjInvCal(double X, double Y, double *longitude, double *latitude){int ProjNo; int ZoneWide; ////带宽double longitude1,latitude1, longitude0,latitude0, X0,Y0, xval,yval;double e1,e2,f,a, ee, NN, T,C, M, D,R,u,fai, iPI;iPI = 0.0174532925199433; ////3.1415926535898/180.0;a = 6378245.0; f = 1.0/298.3; //54年北京坐标系参数////a=6378140.0; f=1/298.257; //80年西安坐标系参数ZoneWide = 6; ////6度带宽ProjNo = (int)(X/1000000L) ; //查找带号longitude0 = (ProjNo-1) * ZoneWide + ZoneWide / 2;longitude0 = longitude0 * iPI ; //中央经线X0 = ProjNo*1000000L+500000L;Y0 = 0;xval = X-X0; yval = Y-Y0; //带内大地坐标e2 = 2*f-f*f;e1 = (1.0-sqrt(1-e2))/(1.0+sqrt(1-e2));ee = e2/(1-e2);M = yval;u = M/(a*(1-e2/4-3*e2*e2/64-5*e2*e2*e2/256));fai = u+(3*e1/2-27*e1*e1*e1/32)*sin(2*u)+(21*e1*e1/16-55*e1*e1*e1*e1/32)*si n(4*u)+(151*e1*e1*e1/96)*sin(6*u)+(1097*e1*e1*e1*e1/512)*sin(8*u);C = ee*cos(fai)*cos(fai);T = tan(fai)*tan(fai);NN = a/sqrt(1.0-e2*sin(fai)*sin(fai));R = a*(1-e2)/sqrt((1-e2*sin(fai)*sin(fai))*(1-e2*sin(fai)*sin(fai))*(1-e2 *sin(fai)*sin(fai)));D = xval/NN;//计算经度(Longitude) 纬度(Latitude)longitude1 = longitude0+(D-(1+2*T+C)*D*D*D/6+(5-2*C+28*T-3*C*C+8*ee+24*T*T)*D*D*D*D*D/120)/cos(fai);latitude1 = fai -(NN*tan(fai)/R)*(D*D/2-(5+3*T+10*C-4*C*C-9*ee)*D*D*D*D/24+(61+90*T+298*C+45*T*T-256*ee-3*C*C)*D*D*D*D*D*D/720);//转换为度 DD*longitude = longitude1 / iPI;*latitude = latitude1 / iPI;}。
大地高斯正反算C

大地高斯正反算-C#代码如下using System;using System.Collections.Generic;using SystemponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace WindowsFormsApplication3public partial class Form1 : Formdouble a, E,E1,bbb;public Form1()InitializeComponent();private void menuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)private void toolStripTextBox1_Click(object sender, EventArgs e)private void toolStripMenuItem1_Click(object sender, EventArgs e)private void button1_Click(object sender,EventArgs e)if (a != 6378245.00 && a != 6378137 && a != 6378137 && a!=6378140)textBox3.Text = "请?选?择?坐?标括?系μ";textBox4.Text = "请?选?择?坐?标括?系μ";elseint du, fen, miao;double B, L, X;double N, x, y, t, n, m, m0, m2, m4, m6, m8,l;B = Convert.ToDouble(textBox1.Text) * Math.PI / 180 + Convert.ToDouble(textBox2.Text)/60 * Math.PI / 180 + Convert.ToDouble(textBox9.Text)/3600 * Math.PI / 180;L = Convert.ToDouble(textBox10.Text) * Math.PI / 180 + Convert.ToDouble(textBox11.Text)/60 * Math.PI / 180 + Convert.ToDouble(textBox12.Text)/3600 * Math.PI / 180; ;l = L - Convert.ToInt16((L-3.0) / 6) * 6-3.0 ;l = l * Math.PI / 180;N = a / Math.Pow(1 - E * Math.Sin(B) * Math.Sin(B), 0.5);m0 = a * (1 - E);m2 = 1.5 * E * m0;m4 = 5 / 4 * E * m2;m6 = 7 / 6 * E * m4;m8 = 9 / 8 * E * m6;X = (m0 + 0.5 * m2 + 3 / 8 * m4 + 5 / 16 * m6 + 35 / 128 * m8) * B - (0.5 * m2 + 0.5 * m4 + 15 / 32 * m6 + 7 / 16 * m8) / 2 * Math.Sin(2 * B) + (m4 / 8 + 3 / 16 * m6 + 7 / 32 * m8) / 4 * Math.Sin(4 * B) - (m6 / 32 + m8 / 16) / 6 * Math.Sin(6 * B) + m8 / 128 / 8 * Math.Sin(8 * B);t = Math.Tan(B);n = Math.Cos(B) * Math.Cos(B) * E1;m = Math.Cos(B) * l;x = X + N / 2 * t * Math.Cos(B) * Math.Cos(B) * l * l + N / 24 * t * (5 - t * t + 9 * n + 4 * n * n) * Math.Pow(Math.Cos(B) * l, 4) + N / 720 * t * (61 - 58 * t * t + t * t * t * t) * Math.Pow(Math.Cos(B) * l, 6);y = N * ((1 + (1 / 6 * (1 - t * t + n) + 1 / 120 * (5 - 18 * t * t + t * t * t * t + 14 * n - 58 * n * t * t) * m * m)* m * m) * m);textBox3.Text = Convert.ToString(x);textBox4.Text = Convert.ToString(y);private void button2_Click(object sender, EventArgs e)int du, fen, miao;if (a != 6378245.00 && a != 6378137 && a != 6378137 && a != 6378140)textBox7.Text = "请?选?择?坐?标括?系μ";textBox8.Text = "请?选?择?坐?标括?系μ";elsedouble Bf, bb, Vf, tf, xf, yf, nf, Nf, B0, l0;xf = Convert.ToDouble(textBox5.Text);yf = Convert.ToDouble(textBox6.Text);bb = xf / bbb;Bf = bb + (50221746 + (293622 + (2350 + 22 * Math.Cos(bb) * Math.Cos(bb)) * Math.Cos(bb) * Math.Cos(bb)) * Math.Cos(bb) * Math.Cos(bb)) * Math.Sin(bb) * Math.Cos(bb) * Math.Pow(10, -10);tf = Math.Tan(Bf);nf = Math.Cos(Bf) * Math.Cos(Bf) * E1;Vf = Math.Pow(1 + E1, 0.5);Nf = a / Math.Pow(1 - E * Math.Sin(Bf) * Math.Sin(Bf), 0.5);B0 = Bf * 180 / Math.PI - 0.5 * Vf * Vf * tf * (yf * yf / Nf / Nf - 1 / 12.00 * (5 + 3 * tf * tf + nf - 9 * nf * tf * tf) * Math.Pow(yf / Nf, 4) + 1 / 360.00 * (61 + 90 * tf * tf + 45 * tf * tf) * Math.Pow(yf / Nf, 6)) * 180 / Math.PI;l0 = 1 / Math.Cos(Bf) * (yf / Nf - 1 / 6 * (1 + 2 * tf * tf + nf) * Math.Pow(yf / Nf, 3) + 1 / 120 * (5 + 28 * tf * tf + 24 * tf * tf + 6 * nf + 8 * nf * tf * tf) * Math.Pow(yf / Nf, 5)) * 180 / Math.PI;du = Convert.ToInt16( Math.Floor(B0));//dufen = Convert.ToInt16( Math.Floor((B0 - Math.Floor(B0)) * 60)); //fenmiao = Convert.ToInt16( Convert.ToInt16( ( (B0 - Math.Floor(B0)) * 60 - Math.Floor((B0 - Math.Floor(B0))* 60) ) * 60));//秒?textBox7.Text = Convert.ToString(du) + "度è"+ Convert.ToString(fen)+"分?"+Convert.ToString(miao)+"秒?";du =Convert.ToInt16(Math.Floor(l0));//dufen = Convert.ToInt16(Math.Floor((l0 - Math.Floor(l0)) * 60)); //fenmiao = Convert.ToInt16(Convert.ToInt16(((l0 - Math.Floor(l0)) * 60 - Math.Floor((l0 - Math.Floor(l0)) * 60)) * 60));//秒?textBox8.Text = Convert.ToString(du) + "度è"+ Convert.ToString(fen) + "分?"+ Convert.ToString(miao) + "秒?";private void toolStripMenuItem2_Click(object sender, EventArgs e)a = 6378245;E = 0.966;E1 = 0.4683;bbb = 6367588.4969;private void toolStripMenuItem3_Click(object sender, EventArgs e)a = 6378137;E = 0.90;E1 = 0.548;bbb = 6367452.133;private void toolStripMenuItem4_Click(objectsender, EventArgs e)a = 6378137;E = 0.13;E1 = 0.227;bbb = 6367452.133;//待鋣定¨private void toolStripMenuItem5_Click(object sender, EventArgs e)a = 6378140;E = 0.9588;E1 = 0.468;//待鋣定¨private void Form1_Load(object sender, EventArgs e)。
高斯投影坐标反算c语言代码

高斯投影坐标反算c语言代码#include<stdio.h>#include<math.h>#include<conio.h>main(){printf("#####################################################\n");printf("# 角度输入说明:如26°12′45.2″输入为26,12,45.2 #\n");printf("#####################################################\n");double x,y;int j,L0;printf("请输入高斯投影坐标(自然坐标),中间用逗号隔开:\n");scanf("%lf,%lf",&x,&y);//自然坐标输入printf("请输入中央子午线L0:\n");scanf("%d,%d,%lf",&L0); //中央子午线输入printf("请选择参考椭球:1.北京1954参考椭球。
\n 2.西安1980参考椭球。
\n");printf("选择的参考椭球为:");scanf("%d",&j);//选择椭球参数if(j==1){long double Bf0=0.157046064172*pow(10,-6)*x;long double Bf=Bf0+cos(Bf0)*(0.005051773759*sin(Bf0)-0.000029837302*pow(sin(Bf0),3)+0.00000023818 9*pow(sin(Bf0),5));long double t=tan(Bf);long double m=0.00673852541468*pow(cos(Bf),2);long double V=1+m;long double N=6378245.000/sqrt(1-0.00669342162297*pow(sin(Bf),2));long double B1=Bf-1.0/2*V*t*pow(y/N,2)+1.0/24*(5+3*pow(t,2)+m-9*m*pow(t,2))*V*t*pow(y/N,4)-1.0/72 0*(61+90*pow(t,2)+45*pow(t,4))*V*t*pow(y/N,6);long double l1=(1/cos(Bf))*(y/N)-1.0/6*(1+2*pow(t,2)+m)*(1/cos(Bf))*pow(y/N,3)+1.0/120*(5+28*pow(t,2)+24*pow(t,4)+6*m+8*m*pow(t,2))*(1/cos(Bf))*pow(y/N,5);long double B=B1*57.29577951;long double l=l1*57.29577951;long double L=L0+l;int d2=int(B);int f2=int((B-d2)*60);long double m2=((B-d2)*60-f2)*60;printf("B=%d %d %.12lf\n",d2,f2,m2);int d3=int(L);int f3=int((L-d3)*60);long double m3=((L-d3)*60-f3)*60;printf("L=%d %d %.12lf\n",d3,f3,m3); //北京1954参考椭球}if(j==2){long double Bf0=0.157048687473*pow(10,-6)*x;long double Bf=Bf0+cos(Bf0)*(0.005052505593*sin(Bf0)-0.000029847335*pow(sin(Bf0),3)+0.0000002416* pow(sin(Bf0),5)+0.0000000022*pow(sin(Bf0),7));long double t=tan(Bf);long double m=0.006739501819473*pow(cos(Bf),2);long double V=1+m;long double N=6378140.000/sqrt(1-0.006694384999588*pow(sin(Bf),2));long double B1=Bf-1.0/2*V*t*pow(y/N,2)+1.0/24*(5+3*pow(t,2)+m-9*m*pow(t,2))*V*t*pow(y/N,4)-1.0/72 0*(61+90*pow(t,2)+45*pow(t,4))*V*t*pow(y/N,6);long double l1=(1/cos(Bf))*(y/N)-1.0/6*(1+2*pow(t,2)+m)*(1/cos(Bf))*pow(y/N,3)+1.0/120*(5+28*pow(t,2)+24*pow(t,4)+6*m+8*m*pow(t,2))*(1/cos(Bf))*pow(y/N,5);long double B=B1*57.29577951;long double l=l1*57.29577951;long double L=L0+l;int d2=int(B);int f2=int((B-d2)*60);long double m2=((B-d2)*60-f2)*60;printf("B=%d %d %.12lf\n",d2,f2,m2);int d3=int(L);int f3=int((L-d2)*60);long double m3=((L-d2)*60-f2)*60;printf("L=%d %d %.12lf\n",d3,f3,m3); //西安1980参考椭球}getch();}。
C++高斯正反算代码

CCoordinate CEarthPlaneDialog::EarthToPlane(const CEarth & earth){double B = earth.m_dB.m_realRadians;double L = earth.m_dL.m_realRadians;L = SetRad_PIPI(L);double L0 = SetL0(L);double X, N, t, t2, m, m2, ng2;double sinB, cosB;X = A1 * B * 180.0 / PI + A2 * sin(2 * B) + A3 * sin(4 * B) + A4 * sin(6 * B);sinB = sin(B);cosB = cos(B);t = tan(B);t2 = t * t;N = a / sqrt(1 - e2 * sinB * sinB);m = cosB * (L - L0);m2 = m * m;ng2 = cosB * cosB * e2 / (1 - e2);double x = X + N * t * ((0.5 + ((5 - t2 + 9 * ng2 + 4 * ng2 * ng2) / 24.0 + (61 - 58 * t2 + t2 * t2) * m2 / 720.0) * m2) * m2);double y = N * m * ( 1 + m2 * ( (1 - t2 + ng2) / 6.0 + m2 * ( 5 - 18 * t2 + t2 * t2 + 14 * ng2 - 58 * ng2 * t2 ) / 120.0));y += 500000;CCoordinate coor(x,y);return coor;}//将大地坐标系转换为平面直角坐标系CEarth CEarthPlaneDialog::PlaneToEarth(const CCoordinate & coor, UINT Sign){double x = coor.m_dX;double y = coor.m_dY;double L0 = (6.0 * Sign - 3.0) / 180 * PI;double sinB, cosB, t, t2, N ,ng2, V, yN;double preB0, B0;double eta;y -= 500000;B0 = x / A1;do{preB0 = B0;B0 = B0 * PI / 180.0;B0 = (x - (A2 * sin(2 * B0) + A3 * sin(4 * B0) + A4 * sin(6 * B0))) / A1;eta = fabs(B0 - preB0);}while(eta > 0.0000000000000001);B0 = B0 * PI / 180.0;sinB = sin(B0);cosB = cos(B0);t = tan(B0);t2 = t * t;N = a / sqrt(1 - e2 * sinB * sinB);ng2 = cosB * cosB * e2 / (1 - e2);V = sqrt(1 + ng2);yN = y / N;double B = B0 - (yN * yN - (5 + 3 * t2 + ng2 - 9 * ng2 * t2) * yN * yN * yN * yN / 12.0 + (61 + 90 * t2 + 45 * t2 * t2) * yN * yN * yN * yN * yN * yN / 360.0) * V * V * t / 2;double L = L0 + (yN - (1 + 2 * t2 + ng2) * yN * yN * yN / 6.0 + (5 + 28 * t2 + 24 * t2 * t2 + 6 * ng2 + 8 * ng2 * t2) * yN * yN * yN * yN * yN / 120.0) / cosB;CEarth earth(B,L,0,'r');return earth;}//将平面直角坐标系转换为大地坐标系void CEarthPlaneDialog::OnRADIOPlane1954(){// TODO: Add your control notification handler code herea = 6378245;f = 298.3;e2 = 1 - ((f - 1) / f) * ((f - 1) / f);e12 = (f / (f - 1)) * (f / (f - 1)) - 1;A1 = 111134.8611;A2 = -16036.4803;A3 = 16.8281;A4 = -0.0220;m_iReferenceFrame = 0;}void CEarthPlaneDialog::OnRADIOPlane1980(){// TODO: Add your control notification handler code herea = 6378140;f = 298.257;e2 = 1 - ((f - 1) / f) * ((f - 1) / f);e12 = (f / (f - 1)) * (f / (f - 1)) - 1;A1 = 111133.0047;A2 = -16038.5282;A3 = 16.8326;A4 = -0.0220;m_iReferenceFrame = 1;}void CEarthPlaneDialog::OnRADIOPlaneWGS84(){// TODO: Add your control notification handler code herea = 6378137;f = 298.257223563;e2 = 1 - ((f - 1) / f) * ((f - 1) / f);e12 = (f / (f - 1)) * (f / (f - 1)) - 1;A1 = 111133.0047;A2 = -16038.5282;A3 = 16.8326;A4 = -0.0220;m_iReferenceFrame = 2;}double CEarthPlaneDialog::SetL0(double L){L = L / PI * 180;if( L > 0 ){for(m_iCincture = 1 ; !(( L >= (6 * m_iCincture - 6 )) & ( L < ( 6 * m_iCincture ))); m_iCincture++){}L0 = 6 * m_iCincture - 3;}else if( L < 0 ){L = -L;for(m_iCincture = 1 ; !(( L > (6 * m_iCincture - 6 )) & ( L <= ( 6 * m_iCincture ))); m_iCincture++){}m_iCincture = 61 - m_iCincture;L0 = m_iCincture * 6 - 363;}else{L0 = 3;m_iCincture = 1;}double temp = ((double)L0) / 180 * PI;return temp;}double CEarthPlaneDialog::SetRad_PIPI(double Rad) {if(Rad > 0){double i = floor(Rad / PI / 2);Rad -= 2 * PI * i;}if(Rad < 0){Rad = -Rad;double i = floor(Rad / PI / 2);Rad -= 2 * PI * i;Rad = -Rad + PI * 2;}if(Rad > PI)Rad -= 2 * PI;return Rad;}。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
高斯投影正反算c代码 Coca-cola standardization office【ZZ5AB-ZZSYT-ZZ2C-ZZ682T-ZZT18】
高斯投影正反算程序设计
一.程序设计流程
本程序的设计思路如下:
(1),程序采用VS08版本作为开发平台,并采用C#语言作为开发语言,设计为WindowsForm窗体程序形式。
(2),程序主要的算法来自于教材。
但是本程序为了更加实用,添加了更多的解算基准,包括:WGS-84,国际椭球1975,克氏椭球,和2000国家大地坐标系。
(3),程序为了更方便的读取数据和输出数据,故需要自己定义了固定的数据输入格式和数据输出格式或形式,请老师注意查看。
二.代码
using System;
using ;
using ;
using ;
using ;
using Gauss
{
public partial class Form1 : Form
{
double b = (a * a * (1 - ee * ee));
double c = a * a / b;
double epp = ((a * a - b * b) / b / b);
CRDGEODETIC pcrdGeo;
CRDCARTESIAN pcrdCar;
double midlong = 0;
//求X,Y和带号
= ;
ytext = ;
string temp = (0, 2);
num = (temp);
ytext = (0, 2);
= (ytext) - 500000;
try
{
tt = }
catch
{
("Choose 3/6 error!");
return;
}
if ("3度带") == 0)
{
midlong = num * 3 * pai / 180;
}
if ("6度带") == 0)
{
midlong = (6 * num - 3) * pai / 180; }
b = (a * a * (1 - ee * ee));
c = a * a / b;
epp = (a * a - b * b) / b;
double m0, m2, m4, m6, m8;
double a0, a2, a4, a6, a8;
m0 = a * (1 - ee * ee);
m2 = / * m0 * ee * ee;
m4 = / * ee * ee * m2;
m6 = / * ee * ee * m4;
m8 = / * ee * ee * m6;
a0 = m0 + m2 / + / * m4 + / * m6 + / * m8;
a2 = m2 / 2 + m4 / 2 + / * m6 + / * m8;
a4 = m4 / + / * m6 + / * m8;
a6 = m6 / + m8 / ;
a8 = m8 / ;
double Bf, B;
Bf = / a0;
B = ;
while (Bf - B) > 1E-10)
{
B = Bf;
double sb = (B);
double cb = (B);
double s2b = sb * cb * 2;
double s4b = s2b * (1 - 2 * sb * sb) * 2;
double s6b = s2b * (1 - s4b * s4b) + s4b * (1 - s2b * s2b); Bf = - (-a2 / * s2b + a4 / * s4b - a6 / * s6b)) / a0; }
double itaf, tf, Vf, Nf;
itaf = epp * (Bf);
tf = (Bf);
Vf = (1 + epp * epp * (Bf) * (Bf));
Nf = c / Vf;
double ynf = / Nf;
= Bf - / * Vf * Vf * tf * (ynf * ynf - / * (ynf, 4) * (5 + 3 * tf * tf + itaf * itaf - 9 * (itaf * tf, 2)) +
/ * (61 + 90 * tf * tf + 45 * (tf, 4)) * (ynf, 6));
= (ynf / (Bf) - (1 + 2 * tf * tf + itaf * itaf) * (ynf, 3) / / (Bf) +
(5 + 28 * tf * tf + 24 * (tf, 4) + 6 * itaf * itaf + 8 * (itaf * tf, 2)) * (ynf, 5) / / (Bf));
= + midlong;
// = ;
= "Results:\nLatitude: " + + "\nLongtitude: " + ;
}
private void label13_Click(object sender, EventArgs e)
{
}
}
}
三.程序运行结果分析
通过选取书上的具体实例进行测试,本程序的精度大体满足要求,一般正算的精度在米和米之间,反算的精度在秒左右。
以下是程序运行的截图。