Builder.cz - Informacni server o programovani

Odběr fotomagazínu

Fotografický magazín "iZIN IDIF" každý týden ve Vašem e-mailu.
Co nového ve světě fotografie!

 

Zadejte Vaši e-mailovou adresu:

Kamarád fotí rád?

Přihlas ho k odběru fotomagazínu!

 

Zadejte e-mailovou adresu kamaráda:



vzdálenosti měst z globálních souřadnic

Seznam témat     Nová odpověď

Přihlásit se     Registrace     Zapomenuté heslo

Re: vzdálenosti měst z globálních souřadnic

Autor: justik

9:50:21 08.09.2010

jj, presne tak, dobra poznamka :-))).

Citovat příspěvek

 

Re: vzdálenosti měst z globálních souřadnic

Autor: tcesky

9:39:42 08.09.2010

[ital] pohybovali bychom se po křivce podobné šroubovici kolem tohoto místa. [/ital]

Ja bych rekl spise "po křivce podobné spirále". Sroubovice je trirozmerny utvar takze bychom zakratko nemohli dychat.

Zdravim

TC

Citovat příspěvek

 

Re: vzdálenosti měst z globálních souřadnic

Autor: justik

9:27:36 08.09.2010

@Luboš:
>> Ano je to výpočet na kouli.
>> Na geoidu to nezvládnu.
Výpočet lze provádět v rovině (tečná rovina ke kouli v některém ze zadávaných bodů či ve středovém bodě ortodromy procházející oběma body), na kouli, elipsoidu, geoidu. Na geoidu je to prakticky neproveditelné, jedná se o složitou plochu vysokého stupně, jejíž tvar se stále upřesňuje měřeními.

Elipsoidy můžete volit dvojího typu:

A) elipsoid referenční, který dobře aproximuje nějakou oblast na Zemi avšak Zemi jako celek neaproximuje dobře. Na našem území chronologicky Zachův elipsoid, Besselův elipsoid, Krasovského elipsoid.

B) elipsoid zemský: aproximuje Zemi jako celek dobře, lokálně má horší vlastnosti. Typicky elipsoid WGS-84.

>> Pokud použiji klasický výpočet vzdáleností na kouli a jako poloměr zeměkoule vezmu aritmetický průměr vzdáleností obou měst ke středu země.
Pokud leží obě města na kouli, koule má v obou místech stejný poloměr. Plést do toho jejich nadmořskou výšku je zbytečné, navíc tato hodnota výpočet neovlivní. I kdyby bylo jedno na MountEverestu a druhé u moře, tak se poloměr (a ůměrně i vzdálenost) změní o 0.15% procent...

Pro účely navigace nemají přímé vzdálenosti smysl. Daleko častěji převádíme města a silniční síť na planární graf, kde ohodnocení hran představuje vážená vzdálenost. Váha závisí na typu komunikace, sklonu terénu a dalších faktorech. Tak můžete zohlednit rozdíl v jízdě po silnici tdruhé třídy jdoucí kopcem a dálnicí...

@Maaartin:
>> Do vzdálenosti 800–1000 km je rozdíl mezi loxodromou a ortodromou zanedbatelný.

Jak kde, loxodroma se limitně blíží k oběma pólům (singulární body), kterých však nikdy nedosáhne. Délka této křivky mezi dvěma nesingulárními body je konečná, pro ostatní případy je nekonečno... Z toho plyne praktický důsledek. Diference mezi délkou loxodromy a ortodromy je funkcí polohy a azimutu. Pokud bychom např. podle kompasu směřovali na jižní magnetický pól, tak bychom k němu nikdy nedošli, pohybovali bychom se po křivce podobné šroubovici kolem tohoto místa.

Citovat příspěvek

 

Re: vzdálenosti měst z globálních souřadnic

Autor: Maaartin

23:41:09 07.09.2010

To vypada na solidni prochazku.
http://cs.wikipedia.org/wiki/Loxodroma
"Do vzdálenosti 800–1000 km je rozdíl mezi loxodromou a ortodromou zanedbatelný."

Citovat příspěvek

 

Re: vzdálenosti měst z globálních souřadnic

Autor: tcesky

20:11:07 07.09.2010

Predpokladam, ze jsi to pocital po ortodrome. Neuskodilo by znat i vzdalenost po loxodrome, pri pochodu podle kompasu se bude hodit.

Zdravim

TC

Citovat příspěvek

 

Re: vzdálenosti měst z globálních souřadnic

Autor: tcesky

20:04:56 07.09.2010

[ital] Ve skutečnost více vzdálenost obou měst budou ovlivňovat nerovnosti terénu,[/ital]
Letadlem - nerovnosti moc nevadi
Autem - Vice vadi zatacky, zejmena doleva.

Jinak ten rozdil v radu stovek metru dobre koresponduje se vseobecnou povedomosti o geodesii a katrografii a malokoho prekvapi.


Zdravim

TC

Citovat příspěvek

 

Re: vzdálenosti měst z globálních souřadnic

Autor: Luboš

19:10:19 07.09.2010

Tak jsem si s tím hrál znovu.

Pokud použiji klasický výpočet vzdáleností na kouli a jako poloměr zeměkoule vezmu aritmetický průměr vzdáleností obou měst ke středu země, získám vzdálenost Praha-Berlín
279.388400 km

Pokud budu předpokládat elipsoid o parametrech udaných WGS-84, pak iteračním postupem (postupným rozdělením na velmi malé části) vypočítám délku křivky, která bude kopírovat povrch elipsoidu (všechna zobrazená místa jsou platná):
279.7181598 km

To znamená, že vzhledem k relativní blízkosti obou měst nebude nebude odchylka obou výpočtů příliš velká.

Ve skutečnost více vzdálenost obou měst budou ovlivňovat nerovnosti terénu, které jsem úplně zanedbal.

Citovat příspěvek

 

Re: vzdálenosti měst z globálních souřadnic

Autor: tcesky

16:55:42 04.09.2010

[ital]Možná někomu bude stačit. [/ital]Ten si to precetl pred deseti tydny.

TC

Citovat příspěvek

 

Re: vzdálenosti měst z globálních souřadnic

Autor: Luboš

16:49:23 04.09.2010

Ano je to výpočet na kouli.
Na geoidu to nezvládnu.
Na druhou stranu je výpočet jednoduchý a rychlý.
Možná někomu bude stačit.
Třeba tomu, kdo tu vzdálenost nemusí vědět úplně přesně na fous.

Citovat příspěvek

 

Re: vzdálenosti měst z globálních souřadnic

Autor: tcesky

16:46:08 04.09.2010

[ital] Počítá se nejkratší vzdálenost po povrchu zeměkoule[/ital]

Pro jaky geoid? Gaussuv nebo Krasovskeho elipsoid?

Zdravim

TC

Citovat příspěvek

 

Re: vzdálenosti měst z globálních souřadnic

Autor: Luboš

16:43:00 04.09.2010

Podle tohoto vzorce:

acos(sin(d1)*sin(d2)+cos(d1)*cos(d2)*cos(s2-s1))

Vychází vzdálenost Praha Berlín: 285.96 km

(Počítá se nejkratší vzdálenost po povrchu zeměkoule)

Citovat příspěvek

 

Re: vzdálenosti měst z globálních souřadnic

Autor: tcesky

16:23:42 04.09.2010

Odkaz to ale resi nad kouli, ne nad geoidem. Nad kouli to umi kazdy zacatecnik takze prinos odkazu je nulovy.

Zdravim

TC

Citovat příspěvek

 

Re: vzdálenosti měst z globálních souřadnic

Autor: Luboš

16:10:16 04.09.2010

Možná pomůže:
http://cs.wikipedia.org/wiki/Ortodroma

Citovat příspěvek

 

Re: vzdálenosti měst z globálních souřadnic

Autor: peta1

8:39:39 24.06.2010

Ono taky je vzdalenost a vzdalenost :) Kdyz to shrnu...
1. zeme je kulata
2. zeme je elipsoid
3. vzdalenost mezi mesty AB muze byt definovana vzdusnou carou (1,2), primou carou skrz zemi, vzdalenosti po silnici, nejkratsi vzdalenosti s vyuzitim vsech prostredku (letadlo, vlak, lod, auto). Otazkou jak to pocita wolframAlfa.

googlem jsem nasel
http://php.vrana.cz/vzdalenost-dvou-zemepisnych-bodu.php
Z te stranky zajimave odkazy
http://www.movable-type.co.uk/scripts/latlong-vincenty.html
(udajne to ma pocitat s presnosti na mm)
http://en.wikipedia.org/wiki/List_of_cities_by_latitude

Berlin 52 31N / 13 25E (Latitude)
Praha 50 05N / 14 26E
279842.081 m

Tceskyho vypocet
Distance Berlin to Prague is 279.373 - 279.683 = -0.310

Wolfram
Praha - Berlin : 281 km

http://www.travelmath.com/city/Berlin,+Germany
berlin 52° 31' 0" N / 13° 24' 0" E
http://cs.wikipedia.org/wiki/Berl%C3%ADn
berlin 52°31′ s. š., 13°24′ v. d.

Citovat příspěvek

 

Re: vzdálenosti měst z globálních souřadnic

Autor: tcesky

12:23:24 23.06.2010

V mem testu, ktery doslova kopiruje Tvuj jsem dosahl shodu na par kilometru. To lze ocekavat protoze vzorce pouzivaji jiny polomer Zeme.

[code]
Distance London to Prague is 1035.204 - 1036.353 = -1.149
Distance Istanbul to Prague is 1508.476 - 1510.151 = -1.675
Distance Kinshasa to Prague is 6044.830 - 6051.541 = -6.710
Distance Algiers to Prague is 1737.332 - 1739.261 = -1.929
Distance Berlin to Prague is 279.373 - 279.683 = -0.310
Distance Alexandria to Prague is 2459.978 - 2462.709 = -2.731
Distance Madrid to Prague is 1773.265 - 1775.234 = -1.969
Distance Roma to Prague is 924.997 - 926.024 = -1.027
Distance Abidjan to Prague is 5265.852 - 5271.698 = -5.846
Distance Kinshasa to Prague is 6044.830 - 6051.541 = -6.710
Distance Izmir to Prague is 1641.949 - 1643.772 = -1.823
Distance Paris to Prague is 883.080 - 884.060 = -0.980
Distance Budapest to Prague is 444.404 - 444.897 = -0.493
Distance Bucharest to Prague is 1081.965 - 1083.166 = -1.201
Distance Tunis to Prague is 1512.031 - 1513.709 = -1.679
Distance Barcelona to Prague is 1351.237 - 1352.737 = -1.500
Distance Hamburg to Prague is 489.301 - 489.844 = -0.543
Distance Warsaw to Prague is 515.794 - 516.367 = -0.573
Distance Milano to Prague is 645.884 - 646.601 = -0.717
Distance Vienna to Prague is 252.010 - 252.289 = -0.280
Distance Douala to Prague is 5133.751 - 5139.450 = -5.699
Distance Lagos to Prague is 4958.012 - 4963.516 = -5.504
Distance Munchen to Prague is 301.154 - 301.488 = -0.334
Distance Napoli to Prague is 1029.733 - 1030.876 = -1.143
Distance Prague to Prague is 0.000 - 0.000 = 0.000
Distance Nyiregyhaza to Prague is 581.647 - 582.292 = -0.646
Distance Ibadan to Prague is 4845.315 - 4850.694 = -5.379
Distance Luanda to Prague is 6548.912 - 6556.182 = -7.270
Distance Sofia to Prague is 1068.012 - 1069.198 = -1.186
Distance Belgrade to Prague is 741.183 - 742.006 = -0.823
Distance Torino to Prague is 754.259 - 755.097 = -0.837
Distance Birmingham to Prague is 1158.313 - 1159.598 = -1.286
Distance Accra to Prague is 5136.298 - 5142.000 = -5.702
Distance Koln to Prague is 536.457 - 537.053 = -0.596
Distance Athens to Prague is 1533.154 - 1534.856 = -1.702
Distance Marseille to Prague is 1022.295 - 1023.430 = -1.135
Distance Tripoli to Prague is 1913.809 - 1915.934 = -2.125
Distance Riga to Prague is 987.606 - 988.702 = -1.096
Distance Lodz to Prague is 400.515 - 400.959 = -0.445
Distance Yaounde to Prague is 5146.028 - 5151.741 = -5.713
Distance Bursa to Prague is 1583.683 - 1585.441 = -1.758
Distance Krakow to Prague is 391.000 - 391.434 = -0.434
Distance Genova to Prague is 756.599 - 757.439 = -0.840
Distance Palermo to Prague is 1332.456 - 1333.935 = -1.479
Distance Leeds to Prague is 1169.073 - 1170.371 = -1.298
Distance Amsterdam to Prague is 708.215 - 709.001 = -0.786
Distance Glasgow to Prague is 1398.922 - 1400.475 = -1.553
Distance Stockholm to Prague is 1050.139 - 1051.305 = -1.166
Distance Oran to Prague is 2006.036 - 2008.263 = -2.227
Distance Frankfurt am Main to Prague is 409.701 - 410.156 = -0.455
Drücken Sie eine beliebige Taste . . .

[color=#0000ff]using[/color][color=#000000] System;
[/color][color=#0000ff]using[/color][color=#000000] System.Collections.Generic;
[/color][color=#0000ff]using[/color][color=#000000] System.Linq;
[/color][color=#0000ff]using[/color][color=#000000] System.Text;

[/color][color=#0000ff]namespace[/color][color=#000000] Lorrien
{
[/color][color=#0000ff]class[/color][color=#000000] [/color][color=#2b91af]Program
[/color][color=#000000] {
[/color][color=#0000ff]static[/color][color=#000000] [/color][color=#0000ff]void[/color][color=#000000] Main([/color][color=#0000ff]string[/color][color=#000000][[/color][color=#000000]] args)
{
[/color][color=#0000ff]foreach[/color][color=#000000] ([/color][color=#0000ff]var[/color][color=#000000] m [/color][color=#0000ff]in[/color][color=#000000] cities) Test(m, cities[[/color][color=#000000]24]);
}
[/color][color=#0000ff]static[/color][color=#000000] [/color][color=#0000ff]void[/color][color=#000000] Test([/color][color=#2b91af]Mesto[/color][color=#000000] mesto1, [/color][color=#2b91af]Mesto[/color][color=#000000] mesto2)
{
[/color][color=#0000ff]double[/color][color=#000000] d1 = getDistance1(mesto1, mesto2);
[/color][color=#0000ff]double[/color][color=#000000] d2 = getDistance2(mesto1, mesto2);
[/color][color=#2b91af]Console[/color][color=#000000].WriteLine([/color][color=#a31515]"Distance {3,-15} to {4,-15} is {0,10:f3} - {1,10:f3} = {2,10:f3}"[/color][color=#000000], d1, d2, d1 - d2, mesto1.name, mesto2.name);
}
[/color][color=#008000]//Pripad 1:
[/color][color=#000000] [/color][color=#0000ff]public[/color][color=#000000] [/color][color=#0000ff]class[/color][color=#000000] [/color][color=#2b91af]Mesto
[/color][color=#000000] {
[/color][color=#0000ff]string[/color][color=#000000] z_name;
[/color][color=#0000ff]int[/color][color=#000000] z_population;
[/color][color=#0000ff]double[/color][color=#000000] z_lon, z_lat;
[/color][color=#0000ff]public[/color][color=#000000] [/color][color=#0000ff]string[/color][color=#000000] name { [/color][color=#0000ff]get[/color][color=#000000] { [/color][color=#0000ff]return[/color][color=#000000] z_name; } }
[/color][color=#0000ff]public[/color][color=#000000] Mesto([/color][color=#0000ff]string[/color][color=#000000] name, [/color][color=#0000ff]double[/color][color=#000000] lon, [/color][color=#0000ff]double[/color][color=#000000] lat, [/color][color=#0000ff]int[/color][color=#000000] population)
{ z_lon = lon; z_lat = lat; z_name = name; z_population = population; }

[/color][color=#0000ff]public[/color][color=#000000] [/color][color=#0000ff]double[/color][color=#000000] getLon() { [/color][color=#0000ff]return[/color][color=#000000] z_lon; }
[/color][color=#0000ff]public[/color][color=#000000] [/color][color=#0000ff]double[/color][color=#000000] getLat() { [/color][color=#0000ff]return[/color][color=#000000] z_lat; }
}
[/color][color=#0000ff]static[/color][color=#000000] [/color][color=#0000ff]double[/color][color=#000000] getDistance1([/color][color=#2b91af]Mesto[/color][color=#000000] mesto1, [/color][color=#2b91af]Mesto[/color][color=#000000] mesto2)
{
[/color][color=#0000ff]double[/color][color=#000000] lon1 = mesto1.getLon() * [/color][color=#2b91af]Math[/color][color=#000000].PI / 180;
[/color][color=#0000ff]double[/color][color=#000000] lat1 = mesto1.getLat() * [/color][color=#2b91af]Math[/color][color=#000000].PI / 180;
[/color][color=#0000ff]double[/color][color=#000000] lon2 = mesto2.getLon() * [/color][color=#2b91af]Math[/color][color=#000000].PI / 180;
[/color][color=#0000ff]double[/color][color=#000000] lat2 = mesto2.getLat() * [/color][color=#2b91af]Math[/color][color=#000000].PI / 180;

[/color][color=#0000ff]double[/color][color=#000000] c = [/color][color=#2b91af]Math[/color][color=#000000].Sin(lat1) * [/color][color=#2b91af]Math[/color][color=#000000].Sin(lat2) +
[/color][color=#2b91af]Math[/color][color=#000000].Cos(lat1) * [/color][color=#2b91af]Math[/color][color=#000000].Cos(lat2) *
[/color][color=#2b91af]Math[/color][color=#000000].Cos(lon1 - lon2);

[/color][color=#0000ff]if[/color][color=#000000] (c > 1) c = 1;
[/color][color=#0000ff]if[/color][color=#000000] (c < -1) c = -1;

c = [/color][color=#2b91af]Math[/color][color=#000000].Acos(c);

[/color][color=#0000ff]double[/color][color=#000000] dist = 6366 * c;

[/color][color=#0000ff]return[/color][color=#000000] dist;
}



[/color][color=#008000]//vysledek cca 245 km

[/color][color=#000000] [/color][color=#008000]//Pripad 2:

[/color][color=#000000] [/color][color=#0000ff]static[/color][color=#000000] [/color][color=#0000ff]double[/color][color=#000000] getDistance2([/color][color=#2b91af]Mesto[/color][color=#000000] mesto1, [/color][color=#2b91af]Mesto[/color][color=#000000] mesto2)
{
[/color][color=#0000ff]double[/color][color=#000000] lon1 = mesto1.getLon() * [/color][color=#2b91af]Math[/color][color=#000000].PI / 180;
[/color][color=#0000ff]double[/color][color=#000000] lat1 = mesto1.getLat() * [/color][color=#2b91af]Math[/color][color=#000000].PI / 180;
[/color][color=#0000ff]double[/color][color=#000000] lon2 = mesto2.getLon() * [/color][color=#2b91af]Math[/color][color=#000000].PI / 180;
[/color][color=#0000ff]double[/color][color=#000000] lat2 = mesto2.getLat() * [/color][color=#2b91af]Math[/color][color=#000000].PI / 180;

[/color][color=#0000ff]double[/color][color=#000000] c = [/color][color=#2b91af]Math[/color][color=#000000].Sin(lat1) * [/color][color=#2b91af]Math[/color][color=#000000].Sin(lat2) +
[/color][color=#2b91af]Math[/color][color=#000000].Cos(lat1) * [/color][color=#2b91af]Math[/color][color=#000000].Cos(lat2) *
[/color][color=#2b91af]Math[/color][color=#000000].Cos(lon1 - lon2);

[/color][color=#0000ff]double[/color][color=#000000] d = [/color][color=#2b91af]Math[/color][color=#000000].PI / 2 - [/color][color=#2b91af]Math[/color][color=#000000].Atan2(c, [/color][color=#2b91af]Math[/color][color=#000000].Sqrt(1 - c * c));
[/color][color=#0000ff]double[/color][color=#000000] dist = 6373.067 * d;

[/color][color=#0000ff]return[/color][color=#000000] dist;
}


[/color][color=#008000]//Vysledek je cca 9765 km, coz je docela rozdil... myslim, ze ten kod je opsany dobre, nebo ne? Proc to porad nevychazi?

[/color][color=#000000] [/color][color=#0000ff]static[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000][[/color][color=#000000]] cities = [/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000][[/color][color=#000000]]{
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"London"[/color][color=#000000],-0.167,51.500,6794400),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Istanbul"[/color][color=#000000],28.950,41.033,6293397),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Kinshasa"[/color][color=#000000],15.300,-4.300,4241000),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Algiers"[/color][color=#000000],3.000,36.801,3705000),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Berlin"[/color][color=#000000],13.417,52.533,3433695),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Alexandria"[/color][color=#000000],29.918,31.216,3295000),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Madrid"[/color][color=#000000],-3.717,40.417,2991223),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Roma"[/color][color=#000000],12.500,41.883,2828692),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Abidjan"[/color][color=#000000],-4.017,5.317,2700000),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Kinshasa"[/color][color=#000000],15.300,-4.300,2653558),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Izmir"[/color][color=#000000],27.167,38.417,2319188),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Paris"[/color][color=#000000],2.333,48.867,2188960),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Budapest"[/color][color=#000000],19.050,47.500,2104700),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Bucharest"[/color][color=#000000],26.117,44.417,1989823),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Tunis"[/color][color=#000000],10.216,36.834,1722000),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Barcelona"[/color][color=#000000],2.167,41.417,1667699),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Hamburg"[/color][color=#000000],10.000,53.550,1652363),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Warsaw"[/color][color=#000000],21.000,52.250,1644700),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Milano"[/color][color=#000000],9.200,45.467,1548580),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Vienna"[/color][color=#000000],16.367,48.217,1531346),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Douala"[/color][color=#000000],9.717,4.067,1500000),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Lagos"[/color][color=#000000],3.467,6.434,1243000),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Munchen"[/color][color=#000000],11.583,48.133,1229026),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Napoli"[/color][color=#000000],14.250,40.833,1207750),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Prague"[/color][color=#000000],14.433,50.100,1203700),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Nyiregyhaza"[/color][color=#000000],21.717,47.950,1190404),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Ibadan"[/color][color=#000000],3.933,7.383,1172000),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Luanda"[/color][color=#000000],13.250,-8.833,1134000),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Sofia"[/color][color=#000000],23.300,42.667,1119152),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Belgrade"[/color][color=#000000],20.500,44.833,1087915),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Torino"[/color][color=#000000],7.667,45.067,1059505),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Birmingham"[/color][color=#000000],-1.833,52.500,992800),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Accra"[/color][color=#000000],-0.250,5.550,949113),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Koln"[/color][color=#000000],6.950,50.933,943551),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Athens"[/color][color=#000000],23.733,38.000,885737),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Marseille"[/color][color=#000000],5.367,43.300,867260),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Tripoli"[/color][color=#000000],13.183,32.900,858500),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Riga"[/color][color=#000000],24.133,56.883,856000),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Lodz"[/color][color=#000000],19.467,51.817,847400),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Yaounde"[/color][color=#000000],11.517,3.850,800000),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Bursa"[/color][color=#000000],29.067,40.200,775388),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Krakow"[/color][color=#000000],19.917,50.050,744000),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Genova"[/color][color=#000000],8.933,44.400,742442),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Palermo"[/color][color=#000000],13.381,38.131,714246),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Leeds"[/color][color=#000000],-1.583,53.833,712200),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Amsterdam"[/color][color=#000000],4.900,52.350,698918),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Glasgow"[/color][color=#000000],-4.250,55.883,689200),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Stockholm"[/color][color=#000000],18.083,59.317,672187),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Oran"[/color][color=#000000],-0.633,35.718,663504),
[/color][color=#0000ff]new[/color][color=#000000] [/color][color=#2b91af]Mesto[/color][color=#000000]([/color][color=#a31515]"Frankfurt am Main"[/color][color=#000000],8.683,50.100,644865),
};

}
}
[/color][/code]
[size=10px]Designed for "uvadeni kodu bez jakehokoliv vysvetleni, ktere mozna pomuze v dany okamzik, ale nic nevyresi do budoucna a takovy clovek se stejne nestane vyvojarem a na slozitejsi otazky uz nedojde"[/size]

Zdravim

TC

Citovat příspěvek

 

Re: vzdálenosti měst z globálních souřadnic

Autor: tcesky

11:09:26 23.06.2010

[code]
[color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080]


[/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] Point in e given distance and bearing from the origin
[/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080]

[/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080][/color][color=#008000]Origin[/color][color=#808080]
[/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080][/color][color=#008000]Direction , degrees from the North[/color][color=#808080]
[/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080][/color][color=#008000]Distance, km[/color][color=#808080]
[/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080][/color][color=#008000]End point[/color][color=#808080]
[/color][color=#000000] [/color][color=#0000ff]static[/color][color=#000000] [/color][color=#0000ff]public[/color][color=#000000] PointF OtherEnd(PointF start, [/color][color=#0000ff]double[/color][color=#000000] bearing, [/color][color=#0000ff]double[/color][color=#000000] dist)
{
[/color][color=#0000ff]if[/color][color=#000000] (dist < 0.001) [/color][color=#0000ff]return[/color][color=#000000] start;
[/color][color=#0000ff]double[/color][color=#000000] c, r, b; [/color][color=#008000]// Valenta 30.01.1989
[/color][color=#000000] [/color][color=#0000ff]double[/color][color=#000000] f2, l2;
[/color][color=#0000ff]double[/color][color=#000000] lon = start.X * [/color][color=#2b91af]Math[/color][color=#000000].PI / 180.0, lat = start.Y * [/color][color=#2b91af]Math[/color][color=#000000].PI / 180.0, azim = NormaliseAnglePositive(bearing) * [/color][color=#2b91af]Math[/color][color=#000000].PI / 180.0;
r = 6366.0;
c = dist / r;
f2 = [/color][color=#2b91af]Math[/color][color=#000000].Sin(lat) * [/color][color=#2b91af]Math[/color][color=#000000].Cos(c) + [/color][color=#2b91af]Math[/color][color=#000000].Cos(lat) * [/color][color=#2b91af]Math[/color][color=#000000].Sin(c) * [/color][color=#2b91af]Math[/color][color=#000000].Cos(azim);
f2 = [/color][color=#2b91af]Math[/color][color=#000000].Asin(f2);

b = [/color][color=#2b91af]Math[/color][color=#000000].Sin(c) * [/color][color=#2b91af]Math[/color][color=#000000].Sin(azim) / [/color][color=#2b91af]Math[/color][color=#000000].Cos(f2);
b = [/color][color=#2b91af]Math[/color][color=#000000].Asin([/color][color=#2b91af]Math[/color][color=#000000].Abs(b));

[/color][color=#0000ff]if[/color][color=#000000] (azim < [/color][color=#2b91af]Math[/color][color=#000000].PI) l2 = lon + b;
[/color][color=#0000ff]else[/color][color=#000000] l2 = lon - b;

[/color][color=#0000ff]if[/color][color=#000000] (l2 > [/color][color=#2b91af]Math[/color][color=#000000].PI) l2 -= 2.0 * [/color][color=#2b91af]Math[/color][color=#000000].PI;
[/color][color=#0000ff]if[/color][color=#000000] (l2 < -[/color][color=#2b91af]Math[/color][color=#000000].PI) l2 += 2.0 * [/color][color=#2b91af]Math[/color][color=#000000].PI;

[/color][color=#008000]//if(l2 > 2.*Math.PI) l2-=2.*Math.PI;
[/color][color=#000000] [/color][color=#008000]//if(l2 < 0. ) l2+=2.*Math.PI;
[/color][color=#000000] [/color][color=#0000ff]if[/color][color=#000000] (f2 > 2.0 * [/color][color=#2b91af]Math[/color][color=#000000].PI) f2 -= 2.0 * [/color][color=#2b91af]Math[/color][color=#000000].PI;
[/color][color=#0000ff]if[/color][color=#000000] (f2 > [/color][color=#2b91af]Math[/color][color=#000000].PI) f2 -= [/color][color=#2b91af]Math[/color][color=#000000].PI;
[/color][color=#0000ff]if[/color][color=#000000] (f2 < -[/color][color=#2b91af]Math[/color][color=#000000].PI) f2 += [/color][color=#2b91af]Math[/color][color=#000000].PI;
[/color][color=#0000ff]return[/color][color=#000000] [/color][color=#0000ff]new[/color][color=#000000] PointF(([/color][color=#0000ff]float[/color][color=#000000])(l2 * 180.0 / [/color][color=#2b91af]Math[/color][color=#000000].PI), ([/color][color=#0000ff]float[/color][color=#000000])(f2 * 180.0 / [/color][color=#2b91af]Math[/color][color=#000000].PI));

}
[/color][color=#808080]///[/color][color=#008000] [/color][color=#808080]
[/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] Distance and bearing from a point to another
[/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080]

[/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080][/color][color=#008000]Starting point[/color][color=#808080]
[/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080][/color][color=#008000]End point[/color][color=#808080]
[/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080][/color][color=#008000]Distance, km[/color][color=#808080]
[/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080][/color][color=#008000]bearing, degrees[/color][color=#808080]
[/color][color=#000000] [/color][color=#0000ff]static[/color][color=#000000] [/color][color=#0000ff]public[/color][color=#000000] [/color][color=#0000ff]void[/color][color=#000000] Distance(PointF start, PointF end, [/color][color=#0000ff]out[/color][color=#000000] [/color][color=#0000ff]double[/color][color=#000000] dist, [/color][color=#0000ff]out[/color][color=#000000] [/color][color=#0000ff]double[/color][color=#000000] azim) [/color][color=#008000]// in kilometres, degrees /* udaje ve stupnich */
[/color][color=#000000] {
Distance(start.X, start.Y, end.X, end.Y, [/color][color=#0000ff]out[/color][color=#000000] dist, [/color][color=#0000ff]out[/color][color=#000000] azim);
}
[/color][color=#808080]///[/color][color=#008000] [/color][color=#808080]
[/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] Distance and bearing from a point to another
[/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080]

[/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080][/color][color=#008000]Longitude of starting point[/color][color=#808080]
[/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080][/color][color=#008000]Latitude of starting point[/color][color=#808080]
[/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080][/color][color=#008000]Longitude of ending point[/color][color=#808080]
[/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080][/color][color=#008000]Latitude of ending point[/color][color=#808080]
[/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080][/color][color=#008000]Distance, km[/color][color=#808080]
[/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080][/color][color=#008000]bearing, degrees[/color][color=#808080]
[/color][color=#000000] [/color][color=#0000ff]static[/color][color=#000000] [/color][color=#0000ff]public[/color][color=#000000] [/color][color=#0000ff]void[/color][color=#000000] Distance([/color][color=#0000ff]double[/color][color=#000000] lon1, [/color][color=#0000ff]double[/color][color=#000000] lat1, [/color][color=#0000ff]double[/color][color=#000000] lon2, [/color][color=#0000ff]double[/color][color=#000000] lat2, [/color][color=#0000ff]out[/color][color=#000000] [/color][color=#0000ff]double[/color][color=#000000] dist, [/color][color=#0000ff]out[/color][color=#000000] [/color][color=#0000ff]double[/color][color=#000000] azim) [/color][color=#008000]// in kilometres, degrees /* udaje ve stupnich */
[/color][color=#000000] {
[/color][color=#0000ff]double[/color][color=#000000] c;

lon1 *= [/color][color=#2b91af]Math[/color][color=#000000].PI/180.0;
lat1 *= [/color][color=#2b91af]Math[/color][color=#000000].PI / 180.0;
lon2 *= [/color][color=#2b91af]Math[/color][color=#000000].PI / 180.0;
lat2 *= [/color][color=#2b91af]Math[/color][color=#000000].PI / 180.0;

c = [/color][color=#2b91af]Math[/color][color=#000000].Sin(lat1) * [/color][color=#2b91af]Math[/color][color=#000000].Sin(lat2)
+ [/color][color=#2b91af]Math[/color][color=#000000].Cos(lat1) * [/color][color=#2b91af]Math[/color][color=#000000].Cos(lat2) * [/color][color=#2b91af]Math[/color][color=#000000].Cos(lon1 - lon2);
[/color][color=#0000ff]if[/color][color=#000000] (c > 1.0) c = 1.0; [/color][color=#0000ff]if[/color][color=#000000] (c < -1.0) c = -1.0;
c = [/color][color=#2b91af]Math[/color][color=#000000].Acos(c);
dist = 6366.0 * c;
[/color][color=#0000ff]if[/color][color=#000000] (c <= 0.0)
{
azim = 0.0;
[/color][color=#0000ff]return[/color][color=#000000];
}
c = [/color][color=#2b91af]Math[/color][color=#000000].Sin(lon1 - lon2) * [/color][color=#2b91af]Math[/color][color=#000000].Cos(lat2) / [/color][color=#2b91af]Math[/color][color=#000000].Sin(c);
[/color][color=#0000ff]if[/color][color=#000000] (c > 1.0) c = 1.0; [/color][color=#0000ff]if[/color][color=#000000] (c < -1.0) c = -1.0;
c = [/color][color=#2b91af]Math[/color][color=#000000].Asin(c);
[/color][color=#0000ff]if[/color][color=#000000] (lat1 >= lat2) c += [/color][color=#2b91af]Math[/color][color=#000000].PI;
[/color][color=#0000ff]if[/color][color=#000000] (lat1 < lat2)
{
[/color][color=#0000ff]if[/color][color=#000000] (lon1 > lon2) c = 2.0 * [/color][color=#2b91af]Math[/color][color=#000000].PI - c;
[/color][color=#0000ff]else[/color][color=#000000] c = [/color][color=#2b91af]Math[/color][color=#000000].Abs(c);
}
azim = c;
azim *= 180.0 / [/color][color=#2b91af]Math[/color][color=#000000].PI;
}

[/color][color=#808080]///[/color][color=#008000] [/color][color=#808080]
[/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] Adjustment of the angle value
[/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080]

[/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080][/color][color=#008000]Angle[/color][color=#808080]
[/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080][/color][color=#008000]Angle normalized to the interval [[/color][color=#008000]0, 360)[/color][color=#808080]
[/color][color=#000000] [/color][color=#0000ff]static[/color][color=#000000] [/color][color=#0000ff]public[/color][color=#000000] [/color][color=#0000ff]double[/color][color=#000000] NormaliseAnglePositive([/color][color=#0000ff]double[/color][color=#000000] d)
{
[/color][color=#0000ff]for[/color][color=#000000] (; d > 360.0; d -= 360.0) ;
[/color][color=#0000ff]for[/color][color=#000000] (; d < 0.0; d += 360.0) ;
[/color][color=#0000ff]return[/color][color=#000000] d;
}
[/color][color=#808080]///[/color][color=#008000] [/color][color=#808080]
[/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] Calculates horizon data for current values
[/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080]

[/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080][/color][color=#008000]Earth curvature[/color][color=#808080]
[/color][color=#000000] [/color][color=#0000ff]public[/color][color=#000000] [/color][color=#0000ff]void[/color][color=#000000] CalculateHorizon([/color][color=#0000ff]double[/color][color=#000000] curv)
{
[/color][color=#0000ff]int[/color][color=#000000] i, n = data.Count;
elevToHorizon = -90;
[/color][color=#0000ff]for[/color][color=#000000] (i = 0; i < n; i++)
{
[/color][color=#0000ff]double[/color][color=#000000] dh = Elevation0 - data[[/color][color=#000000]i].height - ProfilePoint.EarthCorrection(data[[/color][color=#000000]i].dist, curv);
[/color][color=#0000ff]double[/color][color=#000000] d = data[[/color][color=#000000]i].dist;
[/color][color=#0000ff]if[/color][color=#000000] (d > 0)
{
[/color][color=#0000ff]double[/color][color=#000000] a = [/color][color=#2b91af]Math[/color][color=#000000].Atan2(-dh, d * 1000.0) * 180.0 / [/color][color=#2b91af]Math[/color][color=#000000].PI;
[/color][color=#0000ff]if[/color][color=#000000] (a > elevToHorizon)
{
elevToHorizon = a;
distToHorizon = d;
}
}
}
}
}
}
[/color][/code]
[size=10px]Designed for "uvadeni kodu bez jakehokoliv vysvetleni, ktere mozna pomuze v dany okamzik, ale nic nevyresi do budoucna a takovy clovek se stejne nestane vyvojarem a na slozitejsi otazky uz nedojde"[/size]


Zdravim

TC

[/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] Point in e given distance and bearing from the origin [/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080] [/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080][/color][color=#008000]Origin[/color][color=#808080] [/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080][/color][color=#008000]Direction , degrees from the North[/color][color=#808080] [/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080][/color][color=#008000]Distance, km[/color][color=#808080] [/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080][/color][color=#008000]End point[/color][color=#808080] [/color][color=#000000] [/color][color=#0000ff]static[/color][color=#000000] [/color][color=#0000ff]public[/color][color=#000000] PointF OtherEnd(PointF start, [/color][color=#0000ff]double[/color][color=#000000] bearing, [/color][color=#0000ff]double[/color][color=#000000] dist) { [/color][color=#0000ff]if[/color][color=#000000] (dist < 0.001) [/color][color=#0000ff]return[/color][color=#000000] start; [/color][color=#0000ff]double[/color][color=#000000] c, r, b; [/color][color=#008000]// Valenta 30.01.1989 [/color][color=#000000] [/color][color=#0000ff]double[/color][color=#000000] f2, l2; [/color][color=#0000ff]double[/color][color=#000000] lon = start.X * [/color][color=#2b91af]Math[/color][color=#000000].PI / 180.0, lat = start.Y * [/color][color=#2b91af]Math[/color][color=#000000].PI / 180.0, azim = NormaliseAnglePositive(bearing) * [/color][color=#2b91af]Math[/color][color=#000000].PI / 180.0; r = 6366.0; c = dist / r; f2 = [/color][color=#2b91af]Math[/color][color=#000000].Sin(lat) * [/color][color=#2b91af]Math[/color][color=#000000].Cos(c) + [/color][color=#2b91af]Math[/color][color=#000000].Cos(lat) * [/color][color=#2b91af]Math[/color][color=#000000].Sin(c) * [/color][color=#2b91af]Math[/color][color=#000000].Cos(azim); f2 = [/color][color=#2b91af]Math[/color][color=#000000].Asin(f2); b = [/color][color=#2b91af]Math[/color][color=#000000].Sin(c) * [/color][color=#2b91af]Math[/color][color=#000000].Sin(azim) / [/color][color=#2b91af]Math[/color][color=#000000].Cos(f2); b = [/color][color=#2b91af]Math[/color][color=#000000].Asin([/color][color=#2b91af]Math[/color][color=#000000].Abs(b)); [/color][color=#0000ff]if[/color][color=#000000] (azim < [/color][color=#2b91af]Math[/color][color=#000000].PI) l2 = lon + b; [/color][color=#0000ff]else[/color][color=#000000] l2 = lon - b; [/color][color=#0000ff]if[/color][color=#000000] (l2 > [/color][color=#2b91af]Math[/color][color=#000000].PI) l2 -= 2.0 * [/color][color=#2b91af]Math[/color][color=#000000].PI; [/color][color=#0000ff]if[/color][color=#000000] (l2 < -[/color][color=#2b91af]Math[/color][color=#000000].PI) l2 += 2.0 * [/color][color=#2b91af]Math[/color][color=#000000].PI; [/color][color=#008000]//if(l2 > 2.*Math.PI) l2-=2.*Math.PI; [/color][color=#000000] [/color][color=#008000]//if(l2 < 0. ) l2+=2.*Math.PI; [/color][color=#000000] [/color][color=#0000ff]if[/color][color=#000000] (f2 > 2.0 * [/color][color=#2b91af]Math[/color][color=#000000].PI) f2 -= 2.0 * [/color][color=#2b91af]Math[/color][color=#000000].PI; [/color][color=#0000ff]if[/color][color=#000000] (f2 > [/color][color=#2b91af]Math[/color][color=#000000].PI) f2 -= [/color][color=#2b91af]Math[/color][color=#000000].PI; [/color][color=#0000ff]if[/color][color=#000000] (f2 < -[/color][color=#2b91af]Math[/color][color=#000000].PI) f2 += [/color][color=#2b91af]Math[/color][color=#000000].PI; [/color][color=#0000ff]return[/color][color=#000000] [/color][color=#0000ff]new[/color][color=#000000] PointF(([/color][color=#0000ff]float[/color][color=#000000])(l2 * 180.0 / [/color][color=#2b91af]Math[/color][color=#000000].PI), ([/color][color=#0000ff]float[/color][color=#000000])(f2 * 180.0 / [/color][color=#2b91af]Math[/color][color=#000000].PI)); } [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080] [/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] Distance and bearing from a point to another [/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080] [/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080][/color][color=#008000]Starting point[/color][color=#808080] [/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080][/color][color=#008000]End point[/color][color=#808080] [/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080][/color][color=#008000]Distance, km[/color][color=#808080] [/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080][/color][color=#008000]bearing, degrees[/color][color=#808080] [/color][color=#000000] [/color][color=#0000ff]static[/color][color=#000000] [/color][color=#0000ff]public[/color][color=#000000] [/color][color=#0000ff]void[/color][color=#000000] Distance(PointF start, PointF end, [/color][color=#0000ff]out[/color][color=#000000] [/color][color=#0000ff]double[/color][color=#000000] dist, [/color][color=#0000ff]out[/color][color=#000000] [/color][color=#0000ff]double[/color][color=#000000] azim) [/color][color=#008000]// in kilometres, degrees /* udaje ve stupnich */ [/color][color=#000000] { Distance(start.X, start.Y, end.X, end.Y, [/color][color=#0000ff]out[/color][color=#000000] dist, [/color][color=#0000ff]out[/color][color=#000000] azim); } [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080] [/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] Distance and bearing from a point to another [/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080] [/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080][/color][color=#008000]Longitude of starting point[/color][color=#808080] [/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080][/color][color=#008000]Latitude of starting point[/color][color=#808080] [/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080][/color][color=#008000]Longitude of ending point[/color][color=#808080] [/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080][/color][color=#008000]Latitude of ending point[/color][color=#808080] [/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080][/color][color=#008000]Distance, km[/color][color=#808080] [/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080][/color][color=#008000]bearing, degrees[/color][color=#808080] [/color][color=#000000] [/color][color=#0000ff]static[/color][color=#000000] [/color][color=#0000ff]public[/color][color=#000000] [/color][color=#0000ff]void[/color][color=#000000] Distance([/color][color=#0000ff]double[/color][color=#000000] lon1, [/color][color=#0000ff]double[/color][color=#000000] lat1, [/color][color=#0000ff]double[/color][color=#000000] lon2, [/color][color=#0000ff]double[/color][color=#000000] lat2, [/color][color=#0000ff]out[/color][color=#000000] [/color][color=#0000ff]double[/color][color=#000000] dist, [/color][color=#0000ff]out[/color][color=#000000] [/color][color=#0000ff]double[/color][color=#000000] azim) [/color][color=#008000]// in kilometres, degrees /* udaje ve stupnich */ [/color][color=#000000] { [/color][color=#0000ff]double[/color][color=#000000] c; lon1 *= [/color][color=#2b91af]Math[/color][color=#000000].PI/180.0; lat1 *= [/color][color=#2b91af]Math[/color][color=#000000].PI / 180.0; lon2 *= [/color][color=#2b91af]Math[/color][color=#000000].PI / 180.0; lat2 *= [/color][color=#2b91af]Math[/color][color=#000000].PI / 180.0; c = [/color][color=#2b91af]Math[/color][color=#000000].Sin(lat1) * [/color][color=#2b91af]Math[/color][color=#000000].Sin(lat2) + [/color][color=#2b91af]Math[/color][color=#000000].Cos(lat1) * [/color][color=#2b91af]Math[/color][color=#000000].Cos(lat2) * [/color][color=#2b91af]Math[/color][color=#000000].Cos(lon1 - lon2); [/color][color=#0000ff]if[/color][color=#000000] (c > 1.0) c = 1.0; [/color][color=#0000ff]if[/color][color=#000000] (c < -1.0) c = -1.0; c = [/color][color=#2b91af]Math[/color][color=#000000].Acos(c); dist = 6366.0 * c; [/color][color=#0000ff]if[/color][color=#000000] (c <= 0.0) { azim = 0.0; [/color][color=#0000ff]return[/color][color=#000000]; } c = [/color][color=#2b91af]Math[/color][color=#000000].Sin(lon1 - lon2) * [/color][color=#2b91af]Math[/color][color=#000000].Cos(lat2) / [/color][color=#2b91af]Math[/color][color=#000000].Sin(c); [/color][color=#0000ff]if[/color][color=#000000] (c > 1.0) c = 1.0; [/color][color=#0000ff]if[/color][color=#000000] (c < -1.0) c = -1.0; c = [/color][color=#2b91af]Math[/color][color=#000000].Asin(c); [/color][color=#0000ff]if[/color][color=#000000] (lat1 >= lat2) c += [/color][color=#2b91af]Math[/color][color=#000000].PI; [/color][color=#0000ff]if[/color][color=#000000] (lat1 < lat2) { [/color][color=#0000ff]if[/color][color=#000000] (lon1 > lon2) c = 2.0 * [/color][color=#2b91af]Math[/color][color=#000000].PI - c; [/color][color=#0000ff]else[/color][color=#000000] c = [/color][color=#2b91af]Math[/color][color=#000000].Abs(c); } azim = c; azim *= 180.0 / [/color][color=#2b91af]Math[/color][color=#000000].PI; } [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080] [/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] Adjustment of the angle value [/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080] [/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080][/color][color=#008000]Angle[/color][color=#808080] [/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080][/color][color=#008000]Angle normalized to the interval [[/color][color=#008000]0, 360)[/color][color=#808080] [/color][color=#000000] [/color][color=#0000ff]static[/color][color=#000000] [/color][color=#0000ff]public[/color][color=#000000] [/color][color=#0000ff]double[/color][color=#000000] NormaliseAnglePositive([/color][color=#0000ff]double[/color][color=#000000] d) { [/color][color=#0000ff]for[/color][color=#000000] (; d > 360.0; d -= 360.0) ; [/color][color=#0000ff]for[/color][color=#000000] (; d < 0.0; d += 360.0) ; [/color][color=#0000ff]return[/color][color=#000000] d; } [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080] [/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] Calculates horizon data for current values [/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080] [/color][color=#000000] [/color][color=#808080]///[/color][color=#008000] [/color][color=#808080][/color][color=#008000]Earth curvature[/color][color=#808080] [/color][color=#000000] [/color][color=#0000ff]public[/color][color=#000000] [/color][color=#0000ff]void[/color][color=#000000] CalculateHorizon([/color][color=#0000ff]double[/color][color=#000000] curv) { [/color][color=#0000ff]int[/color][color=#000000] i, n = data.Count; elevToHorizon = -90; [/color][color=#0000ff]for[/color][color=#000000] (i = 0; i < n; i++) { [/color][color=#0000ff]double[/color][color=#000000] dh = Elevation0 - data[[/color][color=#000000]i].height - ProfilePoint.EarthCorrection(data[[/color][color=#000000]i].dist, curv); [/color][color=#0000ff]double[/color][color=#000000] d = data[[/color][color=#000000]i].dist; [/color][color=#0000ff]if[/color][color=#000000] (d > 0) { [/color][color=#0000ff]double[/color][color=#000000] a = [/color][color=#2b91af]Math[/color][color=#000000].Atan2(-dh, d * 1000.0) * 180.0 / [/color][color=#2b91af]Math[/color][color=#000000].PI; [/color][color=#0000ff]if[/color][color=#000000] (a > elevToHorizon) { elevToHorizon = a; distToHorizon = d; } } } } } } [/color][/code] [size=10px]Designed for "uvadeni kodu bez jakehokoliv vysvetleni, ktere mozna pomuze v dany okamzik, ale nic nevyresi do budoucna a takovy clovek se stejne nestane vyvojarem a na slozitejsi otazky uz nedojde"[/size] Zdravim TC

Citovat příspěvek

 

Re: vzdálenosti měst z globálních souřadnic

Autor: tcesky

10:50:09 23.06.2010

[ital]Jenom bych se rad dozvedel, jestli se nekde daji sehnat presne vzdalenosti? At vim, jestli muj vypocet je spravny, nebo tomu jeste neco chybi...[/ital]

Jake vzdalenosti? Po loxodrome, po ortodrome nebo snad solid angle v satellite-centricke soustave?


Na jake Zemi? Koule, elipsoid? Jaky elipsoid?
V jakem souradnem systemu jsou souradnice bodu na Zemi?


TC

Citovat příspěvek

 

Re: vzdálenosti měst z globálních souřadnic

Autor: Lorrien

19:34:10 22.06.2010

Tak sem zjistil, ze na ruznych webech vychazeji ty hodnoty odlisne, dokonce i ty, co vychazeji me, takze se s timto spokojim... Dekuji moc vsem zucastnenym za pomoc

Citovat příspěvek

 

Re: vzdálenosti měst z globálních souřadnic

Autor: Lorrien

18:51:46 22.06.2010

Když už sem u toho, ten první výpočet sem si vyzkoušel na těch zkušebních městech, a výsledek už vypadá vcelku dobře:

Praha - Berlin : WA = 281 km, vypocet = 279 km
Praha - Warszawa : WA = 521 km, vypocet = 516 km
Berlin - Warszawa : WA = 521 km, vypocet = 516 km

Tudiz uz to zacina byt dobre. WA = WolframAlpha

Jenom bych se rad dozvedel, jestli se nekde daji sehnat presne vzdalenosti? At vim, jestli muj vypocet je spravny, nebo tomu jeste neco chybi...

Citovat příspěvek

 

Re: vzdálenosti měst z globálních souřadnic

Autor: Lorrien

18:26:43 22.06.2010

TC:

Pripad 1:
[code]
static double getDistance(Mesto mesto1, Mesto mesto2) {
double lon1 = mesto1.getLon() * Math.PI / 180;
double lat1 = mesto1.getLat() * Math.PI / 180;
double lon2 = mesto2.getLon() * Math.PI / 180;
double lat2 = mesto2.getLat() * Math.PI / 180;

double c = Math.sin(lat1) * Math.sin(lat2) +
Math.cos(lat1) * Math.cos(lat2) *
Math.cos(lon1 - lon2);

if(c>1) c = 1;
if(c<-1) c = -1;

c = Math.acos(c);

double dist = 6366 * c;

return dist;
}
[/code]

vysledek cca 245 km

Pripad 2:
[code]
static double getDistance(Mesto mesto1, Mesto mesto2) {
double lon1 = mesto1.getLon() * Math.PI / 180;
double lat1 = mesto1.getLat() * Math.PI / 180;
double lon2 = mesto2.getLon() * Math.PI / 180;
double lat2 = mesto2.getLat() * Math.PI / 180;

double c = Math.sin(lat1) * Math.sin(lat2) +
Math.cos(lat1) * Math.cos(lat2) *
Math.cos(lon1 - lon2);

double d = Math.PI / 2 - Math.atan2(c, Math.sqrt(1-c*c));
double dist = 6373.067 * d;

return dist;
}
[/code]
Vysledek je cca 9765 km, coz je docela rozdil... myslim, ze ten kod je opsany dobre, nebo ne? Proc to porad nevychazi?

Citovat příspěvek

 

Re: vzdálenosti měst z globálních souřadnic

Autor: john008

12:35:46 22.06.2010

> nejaky navrh na zlepseni?

ano, ve vyrazu pro vypocet promenne "a" musi byt u mesta2 rovnez "Y-ova" souradnice,
tj. Math.cos(Math.toRadians(mesto2.getPosY()))

Citovat příspěvek

 

Re: vzdálenosti měst z globálních souřadnic

Autor: Lorrien

8:20:00 22.06.2010

Díky :-D Takova blbost :-D Ja to totiz zkousel porovnavat nejdrive na maps.google, a tam to vidim v 2D prostoru :-D Ale OK, prevedl jsem to na vypocet vzdalenosti na Zemi:

[code]
static double getDistance(Mesto mesto1, Mesto mesto2) {
double R = 6371; // km
double dLat = Math.toRadians(mesto2.getPosY()-mesto1.getPosY());
double dLon = Math.toRadians(mesto2.getPosX()-mesto1.getPosX());
double a = Math.sin(dLat/2) * Math.sin(dLat/2) +
Math.cos(Math.toRadians(mesto1.getPosY())) *
Math.cos(Math.toRadians(mesto2.getPosX())) *
Math.sin(dLon/2) * Math.sin(dLon/2);
double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
double d = R * c;
return d;
}
[/code]

, ale stejne mi stale vychazi divna cisla,,,

Praha - Berlin : 285 km
Praha - Warszawa : 614 km
Berlin - Warszawa : 637 km

nejaky navrh na zlepseni?

Citovat příspěvek

 

Re: vzdálenosti měst z globálních souřadnic

Autor: tcesky

8:11:08 22.06.2010

[code]
void Distance(double lon1, double lat1, double lon2, double lat2, double &dist, double &azim) // in kilometres, degrees /* udaje ve stupnich */
{double c;

lon1*=M_PI/180.;
lat1*=M_PI/180.;
lon2*=M_PI/180.;
lat2*=M_PI/180.;

c=sin(lat1)*sin(lat2)
+cos(lat1)*cos(lat2)*cos(lon1-lon2);
if(c>1.)c=1.; if(c<-1.)c=-1.;
c=acos(c);
dist= 6366.*c;
if(c <= 0.)
{ azim=0.;
return;
}
c=sin(lon1-lon2)*cos(lat2)/sin(c);
if(c>1.)c=1.; if(c<-1.)c=-1.;
c=asin(c);
if(lat1 >=lat2)c+=M_PI;
if(lat1 { if(lon1>lon2)c=2.*M_PI-c;
else c=fabs(c);
}
azim=c;
azim *=180./M_PI;
}

void DistanceKeil(double Lon1, double Lat1, double Lon2, double Lat2, double &Dist, double &Azim)
{ Lon1*=M_PI/180.;
Lat1*=M_PI/180.;
Lon2*=M_PI/180.;
Lat2*=M_PI/180.;
double d=sin(Lat1)*sin(Lat2)+cos(Lat1)*cos(Lat2)*cos(Lon1-Lon2);
d=M_PI/2.-atan2(d,sqrt(1.-d*d));
//d=acos(d);
Dist=6373.067*d;
Azim=0.;
if(d <=0.)return;
if(Lat1 >= M_PI)return;
if(Lat1 <= -M_PI)return;
Azim=(sin(Lat2)-sin(Lat1)*cos(d))/(cos(Lat1)*sin(d));
if(Azim >= 1.){Azim=0.;return;}
if(Azim <= -1.){Azim=180.;return;}
Azim=M_PI/2.-atan2(Azim,sqrt(1.-Azim*Azim));
if(Lon2 < Lon1)Azim=2.*M_PI-Azim;
Azim*=180./M_PI;
}

void OtherEnd(double lon0, double lat0, double dist, double az, double &lon2, double &lat2)
// end point from Azim and Dist
{ double c,r,b; // Valenta 30.01.1989
double f2,l2;
double lon(lon0*M_PI/180.),lat(lat0*M_PI/180.),azim(NormaliseAnglePositive(az)*M_PI/180.);
r=6366.;
c=dist / r;
f2=sin(lat) * cos(c) + cos(lat) * sin(c) * cos(azim);
f2=asin(f2);

b=sin(c) * sin(azim) / cos(f2);
b=asin(fabs(b));

if(azim < M_PI) l2=lon+b;
else l2=lon-b;

if(l2 > M_PI) l2-=2.*M_PI;
if(l2 < -M_PI) l2+=2.*M_PI;

//if(l2 > 2.*M_PI) l2-=2.*M_PI;
//if(l2 < 0. ) l2+=2.*M_PI;
if(f2 > 2.*M_PI) f2-=2.*M_PI;
if(f2 > M_PI ) f2-=M_PI;
if(f2 < -M_PI ) f2+=M_PI;
lon2=l2*180./M_PI;
lat2=f2*180./M_PI;

}

[/code]
Zdravim
TC

Citovat příspěvek

 

Re: vzdálenosti měst z globálních souřadnic

Autor: john008

0:22:53 22.06.2010

>Ahoj, mám souřadnice spousty měst z celého světa. snažím se získat primou vzdalenost z >těchto souřadnic v kilometrech, ale nedaří se mi to.

Bodejt by se ti to darilo, kdyz to podle uvedenych cisel pocitas, jako by mesta byla umistena na rovinne plose. Myslim, ze uz je to docela doba, co lide zjistili, ze Zeme je kulata. :-) Tudiz musi byt jina i metoda vypoctu.

> Nevite o nejakem funkcnim zpusobu na vypocet prime vzdalenosti mezi mesty?

Ano, vim.

Citovat příspěvek

 

vzdálenosti měst z globálních souřadnic

Autor: Lorrien

22:35:13 21.06.2010

Ahoj, mám souřadnice spousty měst z celého světa. snažím se získat primou vzdalenost z těchto souřadnic v kilometrech, ale nedaří se mi to.

Mám např.
Berlín: 13.41, 52.53
Warszawa: 21.00, 52.25
Praha: 14.43, 50.10

Vzdálenosti tedy jsou:
Praha - Berlin : 2.635393708727407
Praha - Warszawa : 6.912843119874774
Berlin - Warszawa : 7.595162934394495

Vzdálenosti podle WolframAplha:
Praha - Berlin : 281 km
Praha - Warszawa : 521 km
Berlin - Warszawa : 521 km

Tedy koeficient (k) pro prepocet neni jednotny:
Praha - Berlin : k = 106.63
Praha - Warszawa : k = 75.37
Berlin - Warszawa : k = 68.6

Nevite o nejakem funkcnim zpusobu na vypocet prime vzdalenosti mezi mesty?

Citovat příspěvek

 

 

 

Přihlášení k mému účtu

Uživatelské jméno:

Heslo: