{"action":"closed","issue":{"url":"https://api.github.com/repos/manuelbieh/Geolib/issues/28","labels_url":"https://api.github.com/repos/manuelbieh/Geolib/issues/28/labels{/name}","comments_url":"https://api.github.com/repos/manuelbieh/Geolib/issues/28/comments","events_url":"https://api.github.com/repos/manuelbieh/Geolib/issues/28/events","html_url":"https://github.com/manuelbieh/Geolib/issues/28","id":29729507,"number":28,"title":"Method to calculate bearing between points","user":{"login":"objectiveSee","id":1684106,"avatar_url":"https://avatars.githubusercontent.com/u/1684106?v=3","gravatar_id":"","url":"https://api.github.com/users/objectiveSee","html_url":"https://github.com/objectiveSee","followers_url":"https://api.github.com/users/objectiveSee/followers","following_url":"https://api.github.com/users/objectiveSee/following{/other_user}","gists_url":"https://api.github.com/users/objectiveSee/gists{/gist_id}","starred_url":"https://api.github.com/users/objectiveSee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/objectiveSee/subscriptions","organizations_url":"https://api.github.com/users/objectiveSee/orgs","repos_url":"https://api.github.com/users/objectiveSee/repos","events_url":"https://api.github.com/users/objectiveSee/events{/privacy}","received_events_url":"https://api.github.com/users/objectiveSee/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/manuelbieh/Geolib/labels/help%20needed","name":"help needed","color":"eb6420"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2014-03-19T12:56:33Z","updated_at":"2015-06-26T08:58:37Z","closed_at":"2015-06-26T08:58:37Z","body":"I implemented a method to calculate bearing between points which could be useful.  Should we add this?\r\n\r\n// From http://www.movable-type.co.uk/scripts/latlong.html\r\nvar bearingFromPoints = function (pointA, pointB) {\r\n\tvar lat1 = pointA.latitude;\r\n\tvar lon1 = pointA.longitude;\r\n\tvar lat2 = pointB.latitude;\r\n\tvar lon2 = pointB.longitude;\r\n\r\n\t// var dLat = (lat2-lat1).toRad();\t// unused\r\n\tvar dLon = (lon2-lon1).toRad();\r\n\t\r\n\tvar y = Math.sin(dLon) * Math.cos(lat2);\r\n\tvar x = Math.cos(lat1)*Math.sin(lat2) - Math.sin(lat1)*Math.cos(lat2)*Math.cos(dLon);\r\n\tvar brng = Math.atan2(y, x).toDeg();\r\n\treturn brng;\r\n};"}}