Talk:Great-circle distance

From Wikipedia, the free encyclopedia

Contents

[edit] Page name

Why is "spherical distance" a better name for this page than great circle distance, which has now been made a redirect page? Is it not standard to speak of "great circle distance"? Michael Hardy 21:26, 5 Oct 2004 (UTC)


I agree, I think the page has been made, while perhaps mathematically correct, harder to understand by introducing the formulas using spherical coordinates instead of latitude and longitude.

I think it's wise to at least break it up into two sections, one for the math principals behind it, and one for a practical use case (latitude and longitude to find distance).

I always intended for it to be easy to understand. --JeremyCole 17:34, Oct 16, 2004 (UTC)

The article says:

Consider a sphere of radius r centered at the origin. That is, the set of all points (x1, x2, x3) such that
x_1^2 + x_2^2 + x_3^2 = r^2
The spherical distance between any two points x and y on this sphere is given by
d(x,y) = r \cos^{-1}\left(\frac{x_1 y_1 + x_2 y_2 + x_3 y_3}{r^2}\right).

Why is this of interest? The spherical distance is r times the angle (in radians). That seems to be the main point. The dot product over r2 is the cosine of the angle. Taking the arccosine of the cosine, after using a needlessly complicated expression for the cosine, when one could have said simply "The spherical distance is r times the angle (in radians)" would be more to the point. Michael Hardy 23:48, 16 Oct 2004 (UTC)

It's useful if you want to see a derivation of the spherical distance formula. You start with your statement (d = r times the angle) then solve for the angle in terms dot product, which leads to the above formula. Then just plug in your favorite spherical coordinates to arrive at the final formula. -- Fropuff 01:27, 2004 Oct 17 (UTC)

[edit] Proof ?

Is it possible to give a proof that it is really a distance ? it has to satisfy these three conditions

acos(P.Q)=0 <=> P=Q
acos(P.Q)=acos(Q.P)
acos(P.Q)<=acos(P.M)+acos(M.Q)

The first two are trivial and the triangle inequality can be shown from the cosines rules of sides (see Haversine formula)

Note that the distance (ab is the same as the angle <AOB on the unit sphere)

The cosines rules of sides states that for a spherical triangle ABC

cos(ac)=cos(ab)cos(bc)+sin(ab)sin(bc)cos(<ABC)

Given that -1<=cos(<ABC)<=1

cos(ac)>=cos(ab)cos(bc)-sin(ab)sin(bc)=cos(ab+bc)

Given that acos is strictly decreasing

We get ac<=ab+bc that is <AOC <= <AOB +<BOC

Sorry for the syntax !

[edit] Polar vs. equatorial (meridional) arcradius

The meridional (vertical, north-south) arcradius ("radius of curvature") variation is relatively inverse to the radius. This is easy to visualize: Picture the transverse equator of an oblate spheroid——i.e., the facing, horizonal meridian (viewed as 2-D, it would be the perimeter of the ellipse). At the poles, where the radius (b) is less than at the equator (a), the arcradius flattens, meaning the "per unit radius of curvature" is greater than the vertical, chordial radius. Conversely, at the equator, where the horizontal radius spreads out, the vertical arc squeezes closer together, so that the per unit value is less than the horizontal radius (which equals the horizontal arcradius, since the equator is a great circle). The actual vertical values are \frac{b^2}{a}\,\! at the equator and \frac{a^2}{b}\,\! at the poles.  ~Kaimbridge~17:27, 12 January 2006 (UTC)

[edit] Parametric equations?

I'm not good enough with my trigonometry, but perhaps someone else would be able to add in the conversions of the arcsine (and maybe even the arctan) solved for φ1 and λ1 rather than the distance. That would be helpful if you know the distance, and you're looking for the point the satisfies it; that's the situation I'm in. I'm trying to draw a circle on a sphere, and so I know the distance (radius), but not the (φ,λ) coordinates of a point on the circle. MidnightLightning 21:50, 13 January 2006 (UTC)

[edit] Dot product

Might it be worthwhile pointing out that the dot product of two unit vectors is the cosine of the angle between them, and that great circle didtance can be computed in this way? —The preceding unsigned comment was added by Pmurray bigpond.com (talkcontribs) 04:26, 13 February 2006 (UTC)

I had that in here at one point (see top of this page), but it got taken out. People seem to prefer complicated formulas. -- Fropuff 04:54, 13 February 2006 (UTC)

[edit] Confusing discussion of relative errors

Previously, the article contained several overly-complicated equations and somewhat misleading discussion of the rounding errors. In particular, it gave six equations:

  \Delta\sigma=\arcsin\left\{\sqrt{\left[\cos\phi_2\sin\Delta\lambda\right]^2+\left[\cos\phi_1\sin\phi_2-\sin\phi_1\cos\phi_2\cos\Delta\lambda\right]^2}\right\},\,\!
=\arccos\left\{\sin\phi_1\sin\phi_2+\cos\phi_1\cos\phi_2\cos\Delta\lambda\right\},\,\!
=\arctan\left\{\frac{\sqrt{\left[\cos\phi_2\sin\Delta\lambda\right]^2+\left[\cos\phi_1\sin\phi_2-\sin\phi_1\cos\phi_2\cos\Delta\lambda\right]^2}}{\sin\phi_1\sin\phi_2+\cos\phi_1\cos\phi_2\cos\Delta\lambda}\right\};\,\!

and

=2\arcsin\left\{\sqrt{\sin\left\{\frac{\phi_2-\phi_1}{2}\right\}^2
+\cos{\phi_1}\cos{\phi_2}\sin\left\{\frac{\Delta\lambda}{2}\right\}^2}\right\},\,\!
=2\arccos\left\{\sqrt{\cos\left\{\frac{\phi_2-\phi_1}{2}\right\}^2-\cos{\phi_1}\cos{\phi_2}\sin\left\{\frac{\Delta\lambda}{2}\right\}^2}\right\},\,\!
=2\arctan\left\{\sqrt{\frac{\sin\left\{\frac{\phi_2-\phi_1}{2}\right\}^2+\cos{\phi_1}\cos{\phi_2}\sin\left\{\frac{\Delta\lambda}{2}\right\}^2}{\cos\left\{\frac{\phi_2-\phi_1}{2}\right\}^2-\cos{\phi_1}\cos{\phi_2}\sin\left\{\frac{\Delta\lambda}{2}\right\}^2}}\right\};\,\!


Of these six, the two arccos versions are inaccurate for small distances due to rounding, but all of the other equations are almost equally accurate for most distances. In particular, the 2arcsin equation, the haversine formula, is perfectly fine for small distances; the article incorrectly stated that it was inaccurate — this would indeed be surprising, since the haversine formula was specifically created for use in navigation and has been used for almost two centuries.

(I wrote a quick C program to check the accuracy for various angles by comparing calculations in double and single precision). As far as I can tell, the haversine formula (the 2arcsin formula) has a very slight edge over the others in accuracy for small distances, which is not surprising since it requires fewer operations and has no fundamental instabilities in that regime.

The advantage of the arctan formula comes for large distances. In particular, for points on almost exactly opposite ends of the sphere, the haversine formula has rounding problems, but the arctan equation is still accurate. In fact, out of the six, it seems to be the only one that maintains high accuracy in all regimes.

I've edited that section of the article to only list the haversine (2arcsin) formula and the inaccurate-but-simple cosine formula, and the arctan formula. There are an infinite variety of other formulas, of course, thanks to trig identities, but I don't see any point to listing them if they have no accuracy or simplicity advantages.

—Steven G. Johnson 02:40, 2 March 2006 (UTC)

I'm the culprit who added the "overly-complicated equations"! P=)
First of all, the full "1arcsin", while the choice for small values, is unacceptable for general application because the result is found from a square root——thus it only recognizes the primary, 0-90°, quadrant! But, beyond its "small value" advantage (plus, you need it for 1arctan, anyways), its components have another major application——azimuth (α1):
SA=\cos\phi_2\sin\Delta\lambda;\,\!
SB=\cos\phi_1\sin\phi_2-\sin\phi_1\cos\phi_2\cos\Delta\lambda;\,\!

then

\Delta\sigma=\arcsin\left(\sqrt{SA^2+SB^2}\right);\,\!
\alpha_1=\arctan\left(\frac{SA}{SB}\right).\,\!
If you are just looking to consolidate appearance, you could redefine as sin(σ), cos(σ) and then define σ from arctan:
\sin\Delta\sigma=\sqrt{\left[\cos\phi_2\sin\Delta\lambda\right]^2+\left[\cos\phi_1\sin\phi_2-\sin\phi_1\cos\phi_2\cos\Delta\lambda\right]^2};\,\!
\cos\Delta\sigma=\sin\phi_1\sin\phi_2+\cos\phi_1\cos\phi_2\cos\Delta\lambda;\,\!
\Delta\sigma=\arctan\left(\frac{\sin\Delta\sigma}{\cos\Delta\sigma}\right).\,\!
But doing it that way upsets the formulatic continuity! P=|
As for the 2arcsin "small distance inaccuracy", yes it is relatively more error-prone. The "C" is just limited to single and double, but other programs/languages may be more flexible. I use UBasic, where precision can be defined to less than .11000!!! Using this little program,
  10 RF=#Pi/180
 100 BLat=(81-0.1^13)*RF:DLat=(81+0.1^10)*RF:MD=0.1^9*RF
 200 SA=cos(DLat)*sin(MD):SB=cos(BLat)*sin(DLat)-sin(BLat)*cos(DLat)*cos(MD)
1000 V1=asin((SA^2+SB^2)^0.5)/RF
1010 V2=acos(sin(BLat)*sin(DLat)+cos(BLat)*cos(DLat)*cos(MD))/RF
1020 V3=2*asin((sin(0.5*(DLat-BLat))^2+cos(BLat)*cos(DLat)*sin(0.5*MD)^2)^0.5)/RF
1030 V4=2*acos((cos(0.5*(DLat-BLat))^2-cos(BLat)*cos(DLat)*sin(0.5*MD)^2)^0.5)/RF
2000 ?"V1=";V1:?"V2=";V2:?"V3";V3:?"V4";V4
The last 4-5 decimals are always error-prone, so they will be ignored:
Point 15 (≈.172)
V1= 0.0000000001857195516152077495375701342520533447749318909192117752252
V2= 0.0000000001857195516152077495375701342520533447749318909192768034706
V3= 0.0000000001857195516152077495375701342520533447749318909191948355277
V4= 0.0000000001857195516152077495375701342520533447749318909199951831628
Point 12 (≈.157)
V1= 0.0000000001857195516152077495375701342520533427367852
V2= 0.0000000001857195516152077495375701342520533525926904
V3= 0.0000000001857195516152077495375701342520533372508105
V4= 0.0000000001857195516152077495375701342520535174730760
Point 7 (≈.133)
V1= 0.0000000001857195516127245757
V2= 0.0000000001857195516212353316
V3= 0.0000000001857195516110224245
V4= 0.0000000001857195517267687042

Point 5 (≈.124)

V1= 0.0000000001805150554
V2= 0.0000000002084408316
V3= 0.0000000001473899255
V4= 0.0000000004168816632
As you can see, V3 (2arcsin) isn't the best choice, in any case! P=) Granted, UBasic doesn't use floating point, so, yes, it will be more prone to error rounding (so just set the "point" value higher), but that means there are other programs (likely not precision adjustable) that are also susceptible. I don't have any fanatical obsession to include all of the different forms——so I won't run over and revert it P=)——I just think, if they are all known (sin, cos and tan) for a given equation version, then they all should be provided (some programs may only utilize arcsin or arccos or arctan). One thing I do want to revert is varphi to phi: Phi, rather than varphi, does seem to be the defacto standard: See Vincenty's formula(PDF))——just keep in mind, in this paper, ''\sigma''=\Delta\sigma\,\! (ellipsoidal, not spherical; likewise λ and α) while \Delta\sigma\,\! is an ellipsoidal cosine multiple series complement for the binomial series expansion approximation.  ~Kaimbridge~16:03, 2 March 2006 (UTC)
Error comparisons in fixed-point are not very relevant in the real world, come on. Even very accurate methods can become horrendously innaccurate in fixed point if careful attention is not paid to scaling. Computer users these days will almost always employ floating point, and the historical users of manual tables would also use floating point (effectively). —Steven G. Johnson 17:48, 2 March 2006 (UTC)

[edit] Example gives incorrect result

It should be around 1562 miles, not 1794 as stated. Have a look at [1] if you don't believe me. Btyner 21:43, 11 October 2006 (UTC)

My bad, I was accidentally using nautical miles Btyner 21:55, 11 October 2006 (UTC)

[edit] Request for formula comparison

Would someone please provide a long/lat pair that demonstrates how each formula is progressively better? -- Myearwood 15:48, February 17, 2007

Look ↑two sections up↑, towards the end: \phi_1\,\! = 80.9999999999999°, \phi_2\,\! = 81.0000000001°, \Delta\lambda\,\! = 0.000000001°. ~Kaimbridge~22:49, 17 February 2007 (UTC)

[edit] Calculator needed

Disappointingly, none of the external links on this article is to a site which lets users enter two sets of coordinates, then returns the distance between them. Do you know of such a site, or a freeware Windows utility, which does that? Andy Mabbett 11:43, 18 April 2007 (UTC)

Whoops, you're right! P=/
Okay, a couple added.  ~Kaimbridge~15:40, 18 April 2007 (UTC)
Thank you. I'm told Google Earth does it, too; and I've suggested that the functionality be added to Geo microformat parsers. Andy Mabbett 16:16, 18 April 2007 (UTC)
I've found a calculator and added it: http://www.wcrl.ars.usda.gov/cec/java/lat-long.htm Joost 99 12:34, 20 August 2007 (UTC)

I just stop to say that I hate the mathematical/too much formal aspect that much of wikipedia article took these days. By mathematicians, for mathematicians. If I want to know why the shortest path in a sphere is not a straight line, I'll have to understand the equations. I hope in the future you will add more pictures —Preceding unsigned comment added by 82.246.191.200 (talk) 04:52, 5 January 2008 (UTC)

[edit] EXCEL Formula

All credits to this page; I have used the formula mentioned on this page to come up with a simple distance calculating formula between the 2 points (WGS84).
=(2*ASIN(SQRT(POWER(SIN((D2/57-B2/57)/2),2)+COS(B2/57)*COS(D2/57)*POWER(SIN((E2/57-C2/57)/2),2))))*6000
Where:
B2 contains latitude (point-1)
C2 contains longitude (point-1)
D2 contains latitude (point-2)
E2 contains longitude (point-2) ... and you get the result in meters; this is the distance between the 2 points.
213.132.61.14 (talk) 11:09, 24 February 2008 (UTC)aqib razzaq

I don't know the particulars of EXCEL, but I see two problems right away:
  • "57" should be \scriptstyle{\frac{180^\circ}{\pi}}\,\!, or 57.295779513...° (or better, its inverse: \scriptstyle{\frac{\pi}{180^\circ}}\,\!, or 0.0174532925199...);
  • "6000" should be "6372.797556" km, or "6372797.556" meters;
Thus, let RF = π/180° and adjust the radius:
DxQm = 2 * 6372797.556 * ASIN(SQRT(POWER(SIN((D2-B2)*RF/2),2)+
COS(B2*RF)*COS(D2*RF)*POWER(SIN((E2-C2)*RF/2),2)))
 ~Kaimbridge~14:46, 24 February 2008 (UTC)

[edit] Problem with formula

As to the distance calculating formula:

{\color{white}\frac{\bigg|}{|}|}\Delta\widehat{\sigma}=\arctan\left(\frac{\sqrt{\left(\cos\phi_f\sin\Delta\lambda\right)^2+\left(\cos\phi_s\sin\phi_f-\sin\phi_s\cos\phi_f\cos\Delta\lambda\right)^2}}{\sin\phi_s\sin\phi_f+\cos\phi_s\cos\phi_f\cos\Delta\lambda}\right);\;\!

I suspect that it gives wrong results for locations in different hemispheres. For instance, if you calculate the distance between Sydney (\lambda_s = 151.2^\circ, \phi_s = -33.9^\circ) and Chicago (\lambda_c = -87.6^\circ, \phi_c = 41.9^\circ) , the outcome of the formula is -5139,3. Can someone clear this out? —Preceding unsigned comment added by 157.193.55.129 (talk) 08:29, 11 April 2008 (UTC)

I have no clue where you got that number! P=) I get \Delta\widehat{\sigma}\approx133.829212^\circ\approx 2.33576\;\mbox{radians}\,\! or \sin(\Delta\widehat{\sigma})\approx.72140725;\quad\cos(\Delta\widehat{\sigma})\approx-.69251107\,\!, what about you?  ~Kaimbridge~13:16, 11 April 2008 (UTC) —Preceding unsigned comment added by Kaimbridge (talkcontribs)

VBA gives me \Delta\widehat{\sigma}\approx -0.80583\;\mbox{radians}\,\!. But I realize my mistake now, you have to add π to make sure that \Delta\widehat{\sigma} \in [0,\pi]\!... —Preceding unsigned comment added by 157.193.55.129 (talk) 12:51, 15 April 2008 (UTC)

[edit] Worked-out example?

The example is not really worked out. It gets 0,45306 by using some angular difference/distance equation, but where are these? I calculated the distance with the spherical law of cosines and got nearly the desired result (1795), however with the harvesine equation I got 1785. So does "difference/distance equation" refer to the law of cosines?? --Jirka6 (talk) 18:53, 28 May 2008 (UTC)