Calculate bearing between 2 points with javascript
问题 I want to calculate the bearing from point 1 to point 2 The input format is 52.070564 - 4.407116 No matter what i try i cannot get an correct output. The formula i use is : // koers berekenen var y = Math.sin(ln-ln1) * Math.cos(lt); var x = Math.cos(lt1)*Math.sin(lt) - Math.sin(lt1)*Math.cos(lt)*Math.cos(ln-ln1); var radians = Math.atan2(y, x); var bearing = Math.round(radians * (180/Math.PI)); /* >>>>>> original <<<<<<< var y = Math.sin(λ2-λ1) * Math.cos(φ2); var x = Math.cos(φ1)*Math.sin(φ2