<과학>하버사인 공식, 구 위의 최단거리를 구하려면

2012. 10. 15. 19:17Tips

How calculate the shortest distance between two points over the sphere?

구(Sphere) 위에서 최단 거리를 구하려면?


지구는 둥그니까... 

우리가 보는 편면 지도 상에서의 

두 지점을 직선으로 잇는 것은,

실제 지구상 최단거리는 아니다.

그래서 이에 대해서 정리한 것이 

Haversine Formula다. 




Haversine Formula에 대해서는 

아래 예시 밑 단에 첨부한다.



Reference(From Wikipedia.org)

'Haversine Formula'

The haversine formula

For any two points on a sphere, the haversine of the central angle between them is given by

\operatorname{haversin}\left(\frac{d}{r}\right) = \operatorname{haversin}(\phi_2 - \phi_1) + \cos(\phi_1) \cos(\phi_2)\operatorname{haversin}(\lambda_2-\lambda_1)

where

\operatorname{haversin}(\theta)=\sin^2\left(\frac{\theta}{2}\right)=\frac{1-\cos(\theta)}{2}
  • d is the distance between the two points (along a great circle of the sphere; see spherical distance),
  • r is the radius of the sphere,
  • \phi_1, \phi_2: latitude of point 1 and latitude of point 2
  • \lambda_1, \lambda_2: longitude of point 1 and longitude of point 2

On the left side of the equals sign d/r is the central angle, assuming angles are measured in in radians (note that φ and &lambda can be converted from degrees to radians by multiplying by π/180 as usual).

Solve for d by applying the inverse haversine (if available) or by using the arcsine (inverse sine) function:

d = r  \operatorname{haversin}^{-1}(h) = 2 r \arcsin\left(\sqrt{h}\right)

where h is haversin(d/r), or more explicitly:

d = 2 r \arcsin\left(\sqrt{\operatorname{haversin}(\phi_2 - \phi_1) + \cos(\phi_1) \cos(\phi_2)\operatorname{haversin}(\lambda_2-\lambda_1)}\right)
 = 2 r \arcsin\left(\sqrt{\sin^2\left(\frac{\phi_2 - \phi_1}{2}\right) + \cos(\phi_1) \cos(\phi_2)\sin^2\left(\frac{\lambda_2 - \lambda_1}{2}\right)}\right)