Przeliczanie współrzędnych geograficznych na kierunek i odległość

0

Witam, mam do napisania w moim programie część odpowiadającą za zwrócenie kierunku od 1 - 359 stopni.
Ogólnie chodzi o to, że samolot wysyła mi co minutę pewne informacje dot. swojego położenia.
Na wejściu posiadam Lat,Lon, jak mógłbym to przekształcić na kierunek? Nie oczekuję odpowiedzi w postaci kodu, jednak jakiegoś naprowadzenia :)
//Podobnie jak zwrot wektora?

Drugie pytanie dotyczy wytyczania odległości. W tym co znalazłem w internecie jeśli chodzi o przeliczanie odległości to wszystko fajnie działa dopóki badane oba obiekty są na tej samej półkuli. Jednak gdy jeden jest na zachodniej, drugi na wschodniej odległości już nie są dokładne i strasznie się rozjeżdżają.

Używam czegoś takiego do wyznaczania odległości:

(acos((sin(rad*Lat1)) * (sin(rad*Lat2)) + (cos(rad*Lat1)) * (cos(rad*Lat2)) * (cos(rad * (Lon2 - Lon1)))) * 6371);

Przedtem było:

( sqrt( ( pow((Lon2 - Lon1), 2) ) + ( pow((Lat2 - Lat1), 2) ) ) * 73 );

Jednak nasza niebieska kulka nie jest kartką papieru i jest zaokrąglona.

Zatem mógłbym liczyć na pomoc :)?

1

Na pierwsze:

This can be done very easily by using the scalar product of two
vectors to find the angle between those vectors. Let the vectors be OA
and OB, where A and B are the two points on the surface of the earth
and O is the centre of the earth. The scalar product gives

OAOBcos(AOB) = R^2*cos(AOB)

where R = radius of the earth. Having found angle AOB the distance
between the points is R*(AOB) with AOB in radians.

To find the scalar product we need the coordinates of the two points.
Set up a three-dimensional coordinate system with the x-axis in the
longitudinal plane of OA, the xy plane containing the equator, and the
z-axis along the earth's axis. With this system, the coordinates of A
will be

Rcos(latA), 0, Rsin(latA)

and the coordinates of B will be

Rcos(latB)cos(lonB-lonA),Rcos(latB)sin(lonB-lonA),Rsin(latB)

The scalar product is given by

xAxB + yAyB + zA*zB
= R2cos(latA)cos(latB)cos(lonB-lonA)+ R2sin(latA)sin(latB)

Dividing out R^2 will give cos(AOB)

cos(AOB)=cos(latA)cos(latB)cos(lonB-lonA)+sin(latA)sin(latB)

This gives AOB, and the great circle distance between A and
B will be

R*(AOB) with AOB in radians.

Na drugie: http://en.wikipedia.org/wiki/Great-circle_distance

0

Dzięki wielkie za odpowiedzi :)

1 użytkowników online, w tym zalogowanych: 0, gości: 1