MCPcopy Create free account
hub / github.com/Smorodov/Multitarget-tracker / Haversine

Function Haversine

example/CarsCounting.h:11–23  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9
10template<typename T>
11T Haversine(const cv::Point_<T>& from, const cv::Point_<T>& to)
12{
13 constexpr T Deg2Rad = static_cast<T>(DEG_TO_RAD);
14
15 T lat_arc = (from.x - to.x) * Deg2Rad;
16 T lon_arc = (from.y - to.y) * Deg2Rad;
17 T lat_h = sin(lat_arc * static_cast<T>(0.5));
18 lat_h *= lat_h;
19 T lon_h = sin(lon_arc * static_cast<T>(0.5));
20 lon_h *= lon_h;
21 T tmp = cos(from.x * Deg2Rad) * cos(to.y * Deg2Rad);
22 return static_cast<T>(2.0) * asin(sqrt(lat_h + tmp * lon_h));
23}
24
25///
26template<typename T>

Callers 1

DistanceInMetersFunction · 0.85

Calls 4

sinFunction · 0.85
cosFunction · 0.85
asinFunction · 0.85
sqrtFunction · 0.85

Tested by

no test coverage detected