As long as the points along your path are spaced at short intervals 
and five seconds does seem like a reasonable sampling rate for an
automobile trip  the sum of the lengths of the line segments will
yield a good approximation of the total distance traveled. You can
improve your precision by increasing the sampling rate or by applying
a smoothing procedure such as spline interpolation to the resulting
points. I really wouldn't worry about it myself.
In any case, you were interested in calculating the distance between
two points specified by longitude, latitude, and altitude. These are
known as polar coordinates, which are convenient on a globe, but for
our purposes we want to know the equivalent Cartesian coordinates.
Given the polar coordinates of a point
p = (long, lat, alt)
we calculate the equivalent Cartesian coordinates
p = (x, y, z)
as follows, where the asterisk denotes multiplication.
x = alt * cos(lat) * sin(long)
y = alt * sin(lat)
z = alt * cos(lat) * cos(long)
If you're interested in a geometric analysis of the polarCartesian
conversion, see the following page.
TopCoder match summary
http://www.topcoder.com/index?t=statistics&c=srm180_prob
You'll have to scroll down to the section headed "Satellites", where
the conversion is described in the context of a computational problem.
If you're familiar with trigonometry, you might find the spherical
diagram helpful. (At the very bottom of the page is a headshot of
yours truly.)
Now, given a pair of points
p0 = (x0, y0, z0)
p1 = (x1, y1, z1)
the distance between them is given by the Pythagorean Theorem extended
to three dimensions. In the equation below, the caret ("^") denotes
exponentiation.
dist = sqrt( (x1x0)^2 + (y1y0)^2 + (z1z0)^2 )
And that's it! So you can solve the problem using nothing more
complicated than the sine, cosine, and squareroot functions.
If you find my answer lacking in any way, please give me a chance to
address your concerns before you assign a rating.
Cheers,
leapinglizard 
Request for Answer Clarification by
radresga
on
08 Apr 2004 14:24 PDT
Your answer sounds promising, but in order for it to be useful, I will
need to know what units the distance calculated will be in. My phone
natively reads lat/long in 1/100,000ths of a degree, and altitude in
meters.

Clarification of Answer by
leapinglizardga
on
08 Apr 2004 23:56 PDT
It doesn't matter what units the angles  longitude and latitude 
are measured in, since you just apply the sine and cosine functions,
each of which returns a real number between 1 and +1. What's decisive
is the unit of measure used for the altitude. If the altitude is
measured in meters, the resulting distance will also be expressed in
meters. You can then convert this to kilometers or miles or what have
you.
Is there anything else I can help you with?
leapinglizard

Request for Answer Clarification by
radresga
on
15 Apr 2004 07:23 PDT
according to
http://mathworld.wolfram.com/SphericalCoordinates.html
the conversion from spherical to cartesian coordinates is as follows:
x = alt * cos(lat) * sin(long)
y = alt * sin(lat) * sin(long)
z = alt * cos(long)
are both formulas equivalent or is there a difference here?

Clarification of Answer by
leapinglizardga
on
15 Apr 2004 10:08 PDT
When applied to your problem, my formula will always yield the same
result as the one derived by Eric Weisstein in his MathWorld article.
However, the formula you have given above is incorrect. I'm afraid
you've misinterpreted the symbols used by Weisstein. His answer is as
follows.
x = alt * cos(long) * sin(90 degr  lat)
y = alt * sin(long) * sin(90 degr  lat)
z = alt * cos(90 degr  lat)
I have transcribed this from his equations (4) through (6). Weisstein
defines the meaning of each symbol in the first paragraph of the
article.
Also note that Weisstein's x, y, and z axes are not oriented in the
same way as mine, but this is merely a difference of notation. Thus,
his coordinates are not in the same order as mine: his x is my z; his
y is my x; his z is my y. When used in the context of the distance
formula
dist = sqrt( (x1x0)^2 + (y1y0)^2 + (z1z0)^2 )
the order doesn't matter, so you'll get the same answer whether you
use Weisstein's notation or mine.
Cheers,
leapinglizard

Request for Answer Clarification by
radresga
on
19 Apr 2004 07:09 PDT
I tried testing out this formula today. I got in my car with my GPS
device and set the trip odometer. At the start of my trip, I had the
following read:
lat: 41.756192 N
long: 87.967360 W
alt: 192m
I drove for about 0.45 miles. At the end of the trip I had the following read:
lat: 41.758701 N
long: 87.973307 W
alt: 198 m
I plugged the numbers into the equation you gave me, and I got 137.973
meters, or 0.0857 miles. Any thoughts on why this isn't working?

Clarification of Answer by
leapinglizardga
on
19 Apr 2004 08:35 PDT
How embarrassing! I forget to mention that the formulas given by Eric
Weisstein and myself use the distance from the center of the earth and
not the elevation above sea level. Of course, Weisstein uses the word
"radius" instead of "altitude", and I should have realized that a GPS
device would report distance from sea level.
This is easily corrected by taking into account the distance between
sea level and the center of the earth, which is about 6370 kilometers.
Thus, before plugging your altitude reading into the formula, you
should add 6,370,000 meters to it.
Using the readings you have supplied above, I obtain a straightline
distance of about 567 meters between the beginning and end of your car
trip. This is reasonably close to your own estimate. Any other
imprecision I would put down to the car odometer, since GPS readings
are much more consistent than any odometer. Also bear in mind that you
are not traveling in a straight line when you take a car trip.
If your calculator doesn't give you a result of 567 meters, make sure
that you're using the trigonometric functions in "degree mode" and not
"radian mode". If the functions only have a radian mode, convert
degrees into radians with the following formula.
rad = deg * 3.14159 / 180.0
Let me know if you're still having trouble.
Cheers,
leapinglizard

Request for Answer Clarification by
radresga
on
21 Apr 2004 07:07 PDT
Unfortunately, introducing the radius of the earth to the equation
takes us back to square one with the Great Circle approach, where
because the radius of the earth is different at different locations it
is impossible to accurately calculate distance. In fact, your
equation now gives results equivalent to the Great Circle formula (190
meters of altitude is not significant enough to affect the radius of
6370km). Is there any other way to accurately determine the distance
between the two points given altitude?

Clarification of Answer by
leapinglizardga
on
21 Apr 2004 10:22 PDT
The radius of the earth does not vary so significantly that it would
affect the precision of an application such as yours, where you are
using commercial GPS readings at relatively close intervals to compute
the length of an automobile trip. As good as it is, a GPS reading
simply isn't precise enough that it can record distortions of distance
caused by the earth's curvature, which are very slight indeed on the
scale of your application.
The mathematical model I used to derive the formulae assumes that the
earth is a sphere, meaning that it has a constant radius. In
principle, one could use the actual radii of the earth at the
locations given by GPS. Once again, however, the error introduced by
the GPS reading is far greater than any gains in precision to be
obtained by this method. There is no measurable advantage to doing so.
If you sense that the formulae are not giving you good approximations
of trip length, I propose that one or more of the following
explanations may obtain. (a) You base your estimate on the car
odometer, which is itself inaccurate. (b) You base your estimate on
personal intuition, which is distorted by the psychological effects of
automobile travel. (c) You are taking GPS intervals at such long
intervals that the resulting line segments are a poor match for the
route you have taken, in which case you should increase your sampling
frequency.
Have you tried applying the formula to a walk or a bicycle ride of
known length, where you can easily stop at frequent intervals to
record the GPS reading? I'm sure you'd be pleased with the results.
leapinglizard
