大地—空間坐標(biāo)轉(zhuǎn)換C#_第1頁
大地—空間坐標(biāo)轉(zhuǎn)換C#_第2頁
大地—空間坐標(biāo)轉(zhuǎn)換C#_第3頁
大地—空間坐標(biāo)轉(zhuǎn)換C#_第4頁
大地—空間坐標(biāo)轉(zhuǎn)換C#_第5頁
已閱讀5頁,還剩3頁未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.IO;using System.Collections ;using System.Text.RegularExpressions;using System.Data.Odbc;namespace大地空間坐標(biāo)系轉(zhuǎn)換public partial class F

2、orm1 : Formpublic Form1()InitializeComponent();private void button1_Click(object sender, EventArgs e)double B, L, H, X, Y, Z, e2, w, N, a;a = 6378137.000000;e2 = 0.00669438;if (textBox1.Text = ) | | (textBox2.Text = )|(textBox3 .Text =) MessageBox.Show(this,請輸入大地坐標(biāo),msg”, MessageBoxButtons.OK,Message

3、BoxIcon.Information);return;B = Convert.ToDouble(textBox1.Text) * Math .PI /180;L = Convert.ToDouble(textBox2.Text) * Math.PI / 180;H = Convert.ToDouble(textBox3.Text);w = Math.Sqrt(1 - e2 * Math.Pow(Math.Sin(B), 2);N = a / w;X = (N + H) * Math.Cos(B) * Math.Cos(L );Y = (N + H) * Math.Cos(B) * Math.

4、Sin(L);Z = (N * (1 - e2) + H) * Math.Sin(B);textBox4.Text = Convert.ToString(X );textBox5.Text = Convert.ToString(Y ); textBox6.Text = Convert.ToString(Z );private void button2_Click(object sender, EventArgs e) double B, L, H, X, Y, Z, e2, w, N, a, e4, p, t, t0, tt, c; a = 6378137.000000;e2 = 0.0066

5、9438;e4 = 0.0067394968;if (textBox4.Text = ) | | (textBox5.Text = ) | | (textBox6.Text =) MessageBox.Show(this,請輸入空間直角坐標(biāo),msg, MessageBoxButtons.OK, MessageBoxIcon.Information);return;B = 0.1;X = Convert.ToDouble(textBox4.Text);Y = Convert.ToDouble(textBox5.Text);Z = Convert.ToDouble(textBox6.Text);

6、L = Math.Atan(Y / X);if (X 0 & Y 0) L = L - Math.PI; else if (X 0) L = L + Math.PI; L = L / Math.PI * 180; t = Math.Tan(B);t0 = Z / Math.Sqrt(X * X + Y * Y);c = a * Math.Sqrt(1 + e4);p = c * e2 / Math.Sqrt(X * X + Y * Y);dott = t;t = t0 + p * t / Math.Sqrt(1 + e4 + t * t); while (-0.000000001 = (t -

7、 tt) | | (t - tt) = 0.000000001);B = Math.Atan(t);w = Math.Sqrt(1 - e2 * Math.Pow(Math.Sin(B ), 2); N = a / w;H = (Math.Sqrt(X * X + Y * Y) / Math.Cos(B) - N);B = B * 180 / Math.PI;textBox1.Text = Convert.ToString(B ); textBox2.Text = Convert.ToString(L ); textBox3.Text = Convert.ToString(H );privat

8、e void button3_Click(object sender, EventArgs e) string no = new string100;doubleB=newdouble100;doubleL=newdouble100;doubleH=newdouble100;doubleX=newdouble100;doubleY=newdouble100;doubleZ=newdouble100;double a = 6378137.000000;double e2 = 0.00669438;double w,N;for (int i = 0; i dataGridView1.Rows.Co

9、unt - 1; i+) noi = this.dataGridView1.Rowsi.Cells0.Value.ToString();Bi = double.Parse(this.dataGridView1.Rowsi.Cells1.Value.ToString() * Math.PI / 180;Li = double.Parse(this.dataGridView1.Rowsi.Cells2.Value.ToString() * Math.PI / 180;Hi = double.Parse(this.dataGridView1.Rowsi.Cells3.Value.ToString()

10、; for (int i = 0; i dataGridView1.Rows.Count - 1; i+)w = Math.Sqrt(1 - e2 * Math.Pow(Math.Sin(Bi), 2);N = a / w;Xi = (N + Hi) * Math.Cos(Bi) * Math.Cos(Li);Yi = (N + Hi) * Math.Cos(Bi) * Math.Sin(Li);Zi = (N * (1 - e2) + Hi) * Math.Sin(Bi);string口 han = new string4;han0 = noi;han1 = Xi.ToString(f4”)

11、;han2 = Yi.ToString(f4”);han3 = Zi.ToString(f4”);this.dataGridView2.Rows.Add(han);private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgse) private void button4_Click(object sender, EventArgs e) OpenFileDialog dig = new OpenFileDialog(); dig.Title =”選擇需要打開的文件”; try if (d

12、ig.ShowDialog() = DialogResult.OK) FileStream fs = new FileStream(dig.FileName, FileMode.Open, FileAccess.Read);FileStream fs2 = new FileStream(dig.FileName, FileMode.Open, FileAccess.Read);StreamReader linenumber = new StreamReader(fs);StreamReader r = new StreamReader(fs2);int line = 0;while (line

13、number.ReadLine() != null)line+;linenumber.Close();fs.Close();int n = 0;for (n = 0; n line; n+)for (n = 0; n line; n+)string asd1 = r.ReadLine();string hang1;hang1 = asd1.Split(new char , ,);dataGridViewl.Rows.Add(hangl);r.Close();fs2.Close();catchMessageBox.Show(this,讀取失敗!,出錯提示);private void button

14、5_Click(object sender, EventArgs e) string no = new string100;doubleX=newdouble100;doubleY=newdouble100;doubleZ=newdouble100;for (inti=0; i dataGridView2.Rows.Count - 1; i+)noi = dataGridView1.Rowsi.Cells0.Value.ToString();Xi = double.Parse(dataGridView1.Rowsi.Cells1.Value.ToString();Yi = double.Par

15、se(dataGridView1.Rowsi.Cells2.Value.ToString();Zi = double.Parse(dataGridView1.Rowsi.Cells2.Value.ToString(); OpenFileDialog dig = new OpenFileDialog(); if (dig.ShowDialog() = DialogResult.OK) FileStream fs = new FileStream(dig.FileName, FileMode.Create, FileAccess.Write);StreamWriter sw = new Strea

16、mWriter(fs);sw.WriteLine(點(diǎn)名t + Xt + Yt + Zt);for (int i = 0; i = dataGridView2.Rows.Count - 2; i+)sw.WriteLine(noi + , + Xi + , + Yi + , + Zi);sw.Close();fs.Close();private void button6_Click(object sender, EventArgs e)this.dataGridView1.Rows.Clear();this.dataGridView2.Rows.Clear();private void butt

17、on7_Click(object sender, EventArgs e)OpenFileDialog dig = new OpenFileDialog(); dig.Title =”選擇需要打開的文件”; tryif (dig.ShowDialog() = DialogResult.OK)FileStream fs = new FileStream(dig.FileName, FileMode.Open, FileAccess.Read);FileStream fs2 = new FileStream(dig.FileName, FileMode.Open, FileAccess.Read)

18、;StreamReader linenumber = new StreamReader(fs);StreamReader r = new StreamReader(fs2);int line = 0;while (linenumber.ReadLine() != null)line+;linenumber.Close();fs.Close();int n = 0;for (n = 0; n line; n+)for (n = 0; n line; n+)string asd1 = r.ReadLine();string hang1;hang1 = asd1.Split(new char , ,

19、 , );dataGridView2.Rows.Add(hang1);r.Close();fs2.Close();catchMessageBox.Show(this,讀取失??!,出錯提示);private void button9_Click(object sender, EventArgs e)string口 no = new string100;double B = new double100;double L = new double100;double H = new double100;for (int i = 0; i dataGridViewl.Rows.Count - 1; i

20、+) noi = dataGridView1.Rowsi.Cells0.Value.ToString();Bi = double.Parse(dataGridView1.Rowsi.Cells1.Value.ToString();Li = double.Parse(dataGridView1.Rowsi.Cells2.Value.ToString();Hi = double.Parse(dataGridView1.Rowsi.Cells2.Value.ToString(); OpenFileDialog dig = new OpenFileDialog();if (dig.ShowDialog

21、() = DialogResult.OK)FileStream fs = new FileStream(dig.FileName, FileMode.Create, FileAccess.Write);StreamWriter sw = new StreamWriter(fs);sw.WriteLine(點(diǎn)名t + Bt + Lt + Ht);for (int i = 0; i = dataGridView1.Rows.Count - 2; i+)sw.WriteLine(noi + , + Bi + , + Li + , + Hi);sw.Close();fs.Close();private

22、 void button8_Click(object sender, EventArgs e)string no = new string100;doubleB=newdouble100;doubleL=newdouble100;doubleH=newdouble100;doubleX=newdouble100;doubleY=newdouble100;doubleZ=newdouble100;double a = 6378137.000000;double e2 = 0.00669438;double e4 = 0.0067394968;double w, N, p, t, t0, tt,

23、c;double T = 0.1;for (int i = 0; i dataGridView2.Rows.Count - 1; i+) noi = this.dataGridView2.Rowsi.Cells0.Value.ToString();Xi = double.Parse(this.dataGridView2.Rowsi.Cells1.Value.ToString();Yi = double.Parse(this.dataGridView2.Rowsi.Cells2.Value.ToString();Zi = double.Parse(this.dataGridView2.Rowsi.Cells3.Value.ToString();for (int i = 0; i dataGridView2.Rows.Count - 1; i+) Li = Math.Atan(Yi / Xi

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論