Click here to Skip to main content
15,919,434 members
Home / Discussions / Algorithms
   

Algorithms

 
QuestionDistance between two GPS points. Pin
chandu00429-Oct-07 2:06
chandu00429-Oct-07 2:06 
AnswerRe: Distance between two GPS points. Pin
V.29-Oct-07 3:12
professionalV.29-Oct-07 3:12 
GeneralRe: Distance between two GPS points. Pin
chandu00429-Oct-07 3:26
chandu00429-Oct-07 3:26 
GeneralRe: Distance between two GPS points. Pin
yuneiv29-Oct-07 4:20
yuneiv29-Oct-07 4:20 
AnswerRe: Distance between two GPS points. Pin
DQNOK29-Oct-07 4:10
professionalDQNOK29-Oct-07 4:10 
JokeOf course straight line... Pin
CPallini29-Oct-07 4:24
mveCPallini29-Oct-07 4:24 
GeneralRe: Of course straight line... Pin
El Corazon29-Oct-07 10:22
El Corazon29-Oct-07 10:22 
AnswerRe: Distance between two GPS points. Pin
El Corazon29-Oct-07 10:22
El Corazon29-Oct-07 10:22 
chandu004 wrote:
is it possible to find the distance in meters between the two points if i have, their longitude, latitude and height.


The short answer: Yes.

The long answer: you need to deal with great-circle (geodesic solution) calculations. See: http://mathworld.wolfram.com/GreatCircle.html[^]

There is also an iterative solution that is often used for boat/air travel. Obviously continuously changing your heading to provide the absolute shortest route to the meter is difficult. So you create waypoints travel to them, change heading and travel to the next, etc., until you reach your destination. This has become easier with computers because a computer auto-pilot will auto-navigate to many more waypoints with micro changes in heading to keep a shorter path. But with ocean travel that is somewhat more difficult.

The question becomes how accurate do you need it, and what is the purpose of the answer. The piece-wise iterative approach would be:
<br />
surfacedistance(from: lat, lon, alt; to: lat, long, alt)<br />
{<br />
 distance= ECEFdistance(ecef(to),ecef(from));<br />
 // choose your desired approximation level for accuracy<br />
 if (distance<1000) return distance;<br />
// else recurse and use piecewise approximation<br />
 ecef_mid=ecef_to*0.5+ecef_from*0.5;<br />
 spher_mid=togeodetic(ecef_mid);<br />
 spher_mid.alt=from.alt*0.5+to.alt*0.5;<br />
 return surfacedistance(from,spher_mid)+surfacedistance(spher_mid,to);<br />
}<br />


or something similar (that is off the top of my head, google piecewise approximation of geodesic distances. The idea is that you can sum a series of vector distances in local space and the more accurate your division, the more accurate the answer. You can choose speed over accuracy at any point by changing the approximation distance change between mid-point division and vector-distance.

The bad news is, if you set the value too low, it is a heavy recursion level and you are better off calculating it directly. There are times in implimentation you may want to do either for other reasons related to use of the answer.

_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)

AnswerRe: Distance between two GPS points. Pin
David Crow1-Nov-07 9:45
David Crow1-Nov-07 9:45 
GeneralRe: Distance between two GPS points. Pin
chandu0042-Nov-07 3:22
chandu0042-Nov-07 3:22 
GeneralRe: Distance between two GPS points. Pin
El Corazon2-Nov-07 10:29
El Corazon2-Nov-07 10:29 
AnswerRe: Distance between two GPS points. Pin
Reagan Conservative2-Nov-07 10:00
Reagan Conservative2-Nov-07 10:00 
AnswerRe: Distance between two GPS points. Pin
RichardM112-Nov-07 13:33
RichardM112-Nov-07 13:33 
QuestionApproximating free hand curve to Beizer Pin
jk chan28-Oct-07 16:26
jk chan28-Oct-07 16:26 
AnswerRe: Approximating free hand curve to Beizer Pin
CPallini29-Oct-07 0:46
mveCPallini29-Oct-07 0:46 
GeneralRe: Approximating free hand curve to Beizer Pin
jk chan29-Oct-07 1:05
jk chan29-Oct-07 1:05 
GeneralI'm a newcomer Pin
yuneiv28-Oct-07 4:18
yuneiv28-Oct-07 4:18 
GeneralRe: I'm a newcomer Pin
User 171649228-Oct-07 10:34
professionalUser 171649228-Oct-07 10:34 
GeneralRe: I'm a newcomer Pin
Paul Conrad28-Oct-07 11:55
professionalPaul Conrad28-Oct-07 11:55 
GeneralRe: I'm a newcomer Pin
yuneiv28-Oct-07 16:38
yuneiv28-Oct-07 16:38 
GeneralRe: I'm a newcomer Pin
Paul Conrad28-Oct-07 16:52
professionalPaul Conrad28-Oct-07 16:52 
GeneralRe: I'm a newcomer Pin
yuneiv29-Oct-07 0:22
yuneiv29-Oct-07 0:22 
GeneralRe: I'm a newcomer Pin
David Crow1-Nov-07 10:00
David Crow1-Nov-07 10:00 
Questionhelp me with this Pin
sushmalodhi27-Oct-07 8:22
sushmalodhi27-Oct-07 8:22 
AnswerRe: help me with this Pin
Paul Conrad27-Oct-07 12:07
professionalPaul Conrad27-Oct-07 12:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.