Implementing Vincenty's Formula in PHP

前端 未结 2 824
清歌不尽
清歌不尽 2021-01-16 06:25

I\'ve been attempting to implement Vincenty\'s formulae with the following:

    /* Implemented using Vincenty\'s formulae from http://en.wikipedia.org/wiki/V         


        
2条回答
  •  终归单人心
    2021-01-16 06:42

    There are a number of errors in transcription from the wikipedia page Direct Problem section:

    • Your u2 expression has 2 in the denominator where it should have b2;
    • Your A and B expressions are inconsistent about whether the initial fraction factor needs to be parenthesised to correctly express a / b * c as (a/b) * c - what happens without parentheses is a php syntax issue which I don't know the answer to, but you should favour clarity;
    • You should be iterating "until there is no significant change in sigma", which may or may not happen in your fixed number of iterations;
    • There are errors in your DELTA_sigma formula:
      • on the wikipedia page, the first term inside the square bracket [ is cos sigma (-1 etc, whereas you have cos (-1 etc, which is very different;
      • in the same formula and also later, note that cos2 x means (cos x)(cos x), not cos cos x!
    • Your phi_2 formula has a sin($sinalpha) where it should have a sin($sinalpha)*sin($sinalpha);

    I think that's all.

提交回复
热议问题