Talk:Great-circle distance

message: 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 \phi_1 and \lambda_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 (\phi, \lambda) coordinates of a point on the circle. MidnightLightning 21:50, 13 January 2006 (UTC)
thread_title:  Parametric equations? 

message: 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 (talk • contribs) 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)
replies: text: Try an example (starting with latitude and longitude of the two points) and use the dot product to calculate the distance. The result won't be unbearably complicated, but it won't be any simpler/quicker than either the law-of-cosines formula or the haversine. Tim Zukas (talk) 18:50, 9 August 2010 (UTC)
thread_title:  Dot product 

message: It should be around 1562 miles, not 1794 as stated. Have a look at  if you don't believe me. Btyner 21:43, 11 October 2006 (UTC)
replies: text: My bad, I was accidentally using nautical miles   Btyner 21:55, 11 October 2006 (UTC)
thread_title:  Example gives incorrect result 

message: 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)
thread_title:  Request for formula comparison 

message: 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)
replies: text: 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)
thread_title: Problem with formula

message: 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)
replies: text: Should be clearer now. But the haversine formula and law of cosines are mathematically equivalent, and will agree closer than that (1785 vs 1795) as long as your calculator has 8+ digits.Tim Zukas (talk) 18:01, 23 August 2010 (UTC)
thread_title: Worked-out example?

message: The article says that the central angle \Delta\widehat{\sigma} can be constituted from the spherical law of cosines, but I take issue with that claim. A spherical triangle connects three points with great circles, and while meridians are great circles, parallels (lines of constant latitude) are not.
Trying to solve this problem on my own, I attempted to use the spherical Pythagorean theorem:
: \cos \left(c\right)=\cos \left(a\right)\,\cos \left(b\right)
This doesn't work because while a delta latitude is measured along a great circle, a delta longitude is not (except at the equator). The spherical law of cosines would work if delta latitude and delta longitude were two sides of a spherical triangle, but not necessarily a right triangle. While I wondered for a while if this could be true, I arrived at the conclusion that it is not.
I believe the math on this page is correct. The only thing I take issue with is the statement that the central angle \Delta\widehat{\sigma} can be found using the spherical law of cosines. I'd love to have someone either back me up on that or help me understand what I'm missing. Butlertd (talk) 17:28, 10 November 2008 (UTC)
replies: text: In terms of the notation in the law of cosines article, one simply considers the special case where u is the north pole, while v and w are the two points whose separation d is to be determined. In that case, a and b are π/2 - φ1,2 (i.e., 90° − latitude), C is the longitude separation Δλ, and c is the desired distance d/R or \Delta\widehat{\sigma}. Noting that sin(π/2 - φ) = cos(φ), the result follows.  —Steven G. Johnson (talk) 00:53, 6 December 2008 (UTC)
thread_title: Law of cosines?

message: Shouldn't what are found as multipliers on the ML actually be exponents on the cosines?
For example, shouldn't this formula:
:KPD_{LON} = 111.41513 \cos(ML) - 0.09455 \cos(3ML) + 0.00012 \cos(5ML)\,\!
Actually be written as:
:KPD_{LON} = 111.41513 \cos(ML) - 0.09455 \cos^3(ML) + 0.00012 \cos^5(ML)\,\!
I didn't find a source which shows the constants as exponents, but I don't see why the terms for variation in KPD should change in sign as mean latitude varies from 0 to 90 degrees. For example, cos(5*ML) is positive at ML = 10°; it is negative at ML = 30°. In contrast, (cos(ML))^5 doesn't become negative at any latitude. - Ac44ck (talk) 18:26, 4 December 2008 (UTC)
replies: text: Nope, they are cosine multiples——those "KPD" equations are binomial series expansions of M and N (see my reply in Talk:Earth radius, including Rapp's Geometric Geodesy, as there is a whole section on this in pt.I, pg.9 P=).  ~Kaimbridge~ (talk) 18:50, 4 December 2008 (UTC)
thread_title:  Typos in FCC prescription? 

message: Why is so much space devoted to crude Pythagorean approximations when exact formulas (on spheres) are available?  Except possibly in very specialized applications, it's hard to believe that the computational savings of the approximate formula are relevant in practice today.  It's not like anyone has to use slide rules or manually interpolate from trigonometric tables anymore.
—Steven G. Johnson (talk) 02:17, 5 December 2008 (UTC)
thread_title:  approximate formulae seem pointless 

message: The comment was recently added that the version of Vincenty's formula in the article is a special case. What makes it a special case? Are there restrictions on the use of the version currently found in the article? -Ac44ck (talk) 04:58, 5 December 2008 (UTC)
replies: text: Vincenty's results were a general iterative method to compute distances on ellipsoids.  The formula in the article is for spheres only.  —Steven G. Johnson (talk) 00:36, 6 December 2008 (UTC)

text: That paragraph should be reworked.  There is nothing special about Vincenty's \scriptstyle{\Delta\widehat{\sigma}}\,\!, the sine valuation (which is what is "special") was used in Sodano's 1965 paper ("General Non-iterative Solution Of The Inverse And Direct Geodetic Problems").  Regarding "suffers from rounding errors for the special (and somewhat unusual) case of antipodal points (on opposite ends of the sphere)" is referring to the auxiliary, ellipsoidal version, \scriptstyle{\Delta\tilde{\sigma}}\,\!, found by using reduced latitudes, an auxiliary longitude difference (involving its own integral) and their transverse companions.  ~Kaimbridge~ (talk) 02:13, 7 December 2008 (UTC)
thread_title:  Special case of Vincenty's formula 

message: A new section called “From two vectors” was newly added, however this solution is already covered in the section “Vector version”. Thus the new section is not needed as a separate section, but it included more explanation, so I have added some more explanation to the “Vector version” section. Isaac Euler (talk) 09:13, 15 April 2011 (UTC)
replies: text: n-vector is just the normal vector to a surface, so it is a strictly mathematical quantity, and not “something geographic” (but it is probably used mostly for geographical problems). Thus it is exactly the same as your vectors (and you should probably choose the atan2 solution for numerical reasons). I see your point that it is easy to believe that n-vector is “something geographic”, but after I added comments about 3D vector algebra, dot and cross products, I think it should now be easier for “non-geographic” readers to realize that the solution you are looking for is found in that section. Isaac Euler (talk) 20:39, 15 April 2011 (UTC)
replies: text: The categories this article is under are Metric geometry and Spherical trigonometry. This article doesn't at all look like it belongs in those categories. In fact, I think a good idea would be to rewrite most of this article so that it sounds like a math article and add some notes on geographic connections in a section including cluttered and obscure "formulae", look at the B class article Stereographic projection for example. -Ben pcc (talk) 21:10, 15 April 2011 (UTC)
thread_title:  Combining new section into existing 

message: I wanted to add an external link to a PHP example of the Haversine and the Vincenty formula, and would have done it in the same manner as the already existing JavaScript link in the section "external links".
http://www.martinstoeckli.ch/php/php.html#great_circle_dist
Reading the guidelines, i stumbled over the point that one should generally not link to a page that is owned or maintained by onself, and that i should ask other editors about adding the link. That's why i ask here, the code is written by myself (no copyrights) and well tested, the page is a long-lasting page.
So, would this link be appreciated, or would it be considered spam-linking?  — Preceding unsigned comment added by Martinstoeckli (talk • contribs) 07:56, 25 October 2012 (UTC)
replies: text: Implementations don't really add to understanding of the topic, so they should be omitted. - MrOllie (talk) 16:58, 25 October 2012 (UTC)
thread_title:  Is this external link to a PHP implementation appreciated? 

message: A recent edit re-inserted the radius in the calculation of the central angle on a unit sphere.
This insertion is erroneous because in the context of this section, "r" is the Earth radius not the radius of the unit sphere. - Ac44ck (talk) 05:46, 18 February 2013 (UTC)
thread_title:  Use Earth radius once in calculation of distance from chord length for unit sphere 

message: This section is for discussing Fgnievinski's tags suggesting moving articles. cffk (talk) 10:36, 30 July 2013 (UTC)
replies: text: Would you reconsider the merge? Fgnievinski (talk) 14:49, 25 December 2013 (UTC)
replies: text: It's fine if you propose a merge once again.  However, I recommend that you make specific recommendations on what is to be merged and how.  And probably you need to be prepared to do some (most?) of the merging.  (And I'll try to pitch in.) cffk (talk) 01:51, 29 December 2013 (UTC)
thread_title:  July 2013 suggestions for merging articles 

message: The Vincenty formula may not be correct; I have spent hours testing it, and it just plain does not work for me.  If I can figure out how to do that, I will delete it.  My test code in Wolfram (Mathematica) Language is shown below.  The test code computes the angle between the Sun and the Moon for the period 8/11/2015 to 9/12/2015.  This code assumes the observer is in Philadelphia, Pennsylvania, USA, but I don't think that matters.
testSphereAngle := 
 Module[{d90 = Quantity[90, "AngularDegrees"], SphereAngle, i, n, sa, 
   sunpos, moonpos, angles = {}, 
   titles = {"Spherical Distance from Mathematica", 
     "Wikipedia Inaccurate", "Wikipedia Haversine", 
     "Wikipedia Haversine using Haversine", "Vincenty Formula", 
     "Vincenty Formula with ArcTan2"}},
  SphereDistance[{\[Phi]11_, \[Lambda]11_}, {\[Phi]12_, \[Lambda]12_}] := 
   Module[{\[Phi]1 = d90 - \[Phi]11, \[Lambda]1 = 
      d90 - \[Lambda]11, \[Phi]2 = d90 - \[Phi]12, \[Lambda]2 = 
      d90 - \[Lambda]12}, 
    InverseHaversine[
     Haversine[\[Phi]1 - \[Phi]2] + 
      Cos[\[Phi]1] Cos[\[Phi]2] Haversine[\[Lambda]1 - \[Lambda]2]]];
  sdw1[{\[Phi]11_, \[Lambda]11_}, {\[Phi]12_, \[Lambda]12_}] := 
   Module[{\[Phi]1 = d90 - \[Phi]11, \[Lambda]1 = 
      d90 - \[Lambda]11, \[Phi]2 = d90 - \[Phi]12, \[Lambda]2 = 
      d90 - \[Lambda]12},
    ArcCos[
     Sin[\[Phi]1]*Sin[\[Phi]2] + 
      Cos[\[Phi]1]*Cos[\[Phi]2]*Cos[Abs[\[Lambda]1 - \[Lambda]2]]]];
  sdw2[{\[Phi]11_, \[Lambda]11_}, {\[Phi]12_, \[Lambda]12_}] := 
   Module[{\[Phi]1 = d90 - \[Phi]11, \[Lambda]1 = 
      d90 - \[Lambda]11, \[Phi]2 = d90 - \[Phi]12, \[Lambda]2 = 
      d90 - \[Lambda]12}, 
    2*ArcSin[
      Sqrt[Sin[Abs[\[Phi]1 - \[Phi]2]/2]^2 + 
        Cos[\[Phi]1]*Cos[\[Phi]2]*
         Sin[Abs[\[Lambda]1 - \[Lambda]2]/2]^2]]];
  sdw3[{\[Phi]11_, \[Lambda]11_}, {\[Phi]12_, \[Lambda]12_}] := 
   Module[{\[Phi]1 = d90 - \[Phi]11, \[Lambda]1 = 
      d90 - \[Lambda]11, \[Phi]2 = d90 - \[Phi]12, \[Lambda]2 = 
      d90 - \[Lambda]12}, 
    2*ArcSin[
      Sqrt[Haversine[Abs[\[Phi]1 - \[Phi]2]] + 
        Cos[\[Phi]1]*Cos[\[Phi]2]*
         Haversine[Abs[\[Lambda]1 - \[Lambda]2]]]]];
  sdw4[{\[Phi]11_, \[Lambda]11_}, {\[Phi]12_, \[Lambda]12_}] := 
   Module[{\[Phi]1 = d90 - \[Phi]11, \[Lambda]1 = 
      d90 - \[Lambda]11, \[Phi]2 = d90 - \[Phi]12, \[Lambda]2 = 
      d90 - \[Lambda]12},
    ArcTan[
     Sqrt[(Cos[\[Phi]2]*
           Sin[Abs[\[Lambda]1 - \[Lambda]2]])^2 + (Cos[\[Phi]1]*
            Sin[\[Phi]2] - 
           
           Sin[\[Phi]1]*Cos[\[Phi]2]*
            Cos[Abs[\[Lambda]1 - \[Lambda]2]])^2]/(Sin[\[Phi]1]*
         Sin[\[Phi]2] + 
        Cos[\[Phi]1]*Cos[\[Phi]2]*Cos[Abs[\[Lambda]1 - \[Lambda]2]])]];
  sdw5[{\[Phi]11_, \[Lambda]11_}, {\[Phi]12_, \[Lambda]12_}] := 
   Module[{\[Phi]1 = d90 - \[Phi]11, \[Lambda]1 = 
      d90 - \[Lambda]11, \[Phi]2 = d90 - \[Phi]12, \[Lambda]2 = 
      d90 - \[Lambda]12}, 
    ArcTan[Sqrt[(Cos[\[Phi]2]*
          Sin[Abs[\[Lambda]1 - \[Lambda]2]])^2 + (Cos[\[Phi]1]*
           Sin[\[Phi]2] - 
          Sin[\[Phi]1]*Cos[\[Phi]2]*
           Cos[Abs[\[Lambda]1 - \[Lambda]2]])^2], -(Sin[\[Phi]1]*
         Sin[\[Phi]2] + 
        Cos[\[Phi]1]*Cos[\[Phi]2]*Cos[Abs[\[Lambda]1 - \[Lambda]2]])]];
  
  SphereAngle = {SphereDistance, sdw1, sdw2, sdw3, sdw4, sdw5};
  n = Length[SphereAngle];
  For[i = 1, i <= n, ++i, sa[i] = SphereAnglei];
  sunpos = 
   SunPosition[
    DateRange[DateObject[{2015, 8, 11, 0, 0, 0}], 
     DateObject[{2015, 9, 12, 0, 0, 0}], {1, "Day"}]]; 
  moonpos = 
   MoonPosition[
    DateRange[DateObject[{2015, 8, 11, 0, 0, 0}], 
     DateObject[{2015, 9, 12, 0, 0, 0}], {1, "Day"}]];
  For[i = 1, i <= n, ++i, 
   AppendTo[angles, 
    TimeSeriesThread[
     Quantity[sa[i][First[#], Last[#]]/Degree, 
       "AngularDegrees"] &, {sunpos, moonpos}]]];
  Print[DateListPlot[angles]];
  For[i = 1, i <= n, ++i,
   Print[DateListPlot[anglesi, 
     PlotLabel -> "Method: " <> titlesi]]]]
CElliott316  — Preceding unsigned comment added by CElliott316 (talk • contribs) 18:26, 16 August 2015 (UTC)
replies: text: Perhaps you forgot that Mathematica using a non-standard convention for the 2-argument form for ArcTan? cffk (talk) 18:53, 16 August 2015 (UTC)
replies: text:  For everyone's information, I implemented the haversine, Vincenty, and Kahan algorithms from the article and they all agree (although the Haversine formula gives about sqrt(epsilon) precision for near-antipodal points). 209.209.238.189 (talk) 21:30, 30 August 2018 (UTC)
thread_title:  Vincenty Formula May Not be Correct 

message: I've added a diagram to this article, and removed the "Mathematical diagram requested" banner. However, I feel that perhaps the article could stand to have a few more diagrams (perhaps explaining some of the mathematical notation). If anyone wants me to make a diagram for something like this just say the word and I'll be happy to do it.  --CheCheDaWaff (talk) 17:20, 14 April 2016 (UTC)
thread_title:  About diagrams 

message: Shouldn't the Great-circle distance article be treated mathematically rather than geographically? i.e. pertaining generalized measurements on a theoretical sphere instead of particularly navigating the Earth. Of course by extension one could apply to any case where a spherical model is involved with the respective particular adaptations.
Hence, the Formulas section should be treated in spherical coordinates with r, θ, φ instead of latitude/longitude space.
After all, why not benefit all disciplines instead of just one?--Amirea (talk) 17:16, 8 July 2017 (UTC)
replies: text: You have a point, but the problem is the multiple conflicting conventions for spherical coordinates.  There's the ISO (physics) convention where θ is the polar angle (colatitude = 90° − latitude) and φ is the azimuth (longitude), and then there's the mathematical convention that's the other way around!  At least the geographical convention of −90° ≤ φ ≤  90° is latitude and −180° ≤ λ ≤  180° is longitude is well understood. 209.209.238.189 (talk) 21:26, 30 August 2018 (UTC)

text: I recommend sticking with latitude and longitude.  cffk (talk) 21:30, 30 August 2018 (UTC)
thread_title:  Spherical coordinates versus latitude/longitude coordinates 

message: The article introduced the following formula as one that works for *all distances*. 
:\Delta\sigma =
  \arctan \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)} .
But, it seems not. For example, if we have \Delta\lambda = 0, we have
:
\Delta\sigma = \arctan \frac{|\sin(\theta_1-\theta_2)|}{\cos(\theta_1-\theta_2)} 
Let's say \theta_1 = \pi/2 and \theta_2=-\pi/2, then we should have \Delta\sigma=\pi. But, the formula above yields 0. 
Ylee15 (talk) 16:11, 11 August 2022 (UTC)
replies: text: I've fixed the article to explain how the quadrant of \Delta\sigma should be chosen. cffk (talk) 18:26, 11 August 2022 (UTC)
replies: text: I've rewritten the formula to explicitly use atan2, per https://github.com/geopy/geopy/blob/f495974c32a7a7b1eb433e7b8c87166e96375c32/geopy/distance.py#L464. Artoria2e5 🌉 04:57, 29 May 2024 (UTC)
thread_title:  Caution on using Vincenty formula