1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | function toRadians(degree) { return degree * Math.PI / 180 } function distance(latitude1, longitude1, latitude2, longitude2) { // R은 지구의 반지름, 단위는 km var R = 6371 ; var deltaLatitude = (latitude2 - latitude1).toRadians(); var deltaLongitude = (longitude2 - longitude1).toRadians(); latitude1 = latitude1.toRadians(),latitude2 = latitude2.toRadians(); var a = Math.sin(deltaLatitude / 2 ) * Math.sin(deltaLatitude / 2 ) + Math.cos(latitude1) * Math.cos(latitude2) * Math.sin(deltaLongitude / 2 ) * Math.sin(deltaLongitude / 2 ); var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt( 1 - a)); var d = R * c; return d; } |
'하버사인 공식'에 해당되는 글 1건
- 2011.08.04 하버사인 공식
미등록2011. 8. 4. 10:15