Commit 8d1a4775 by LEFEBVREJP email

### Adding greatCircleDistance and haversine formula.

parent 3e264b97
Pipeline #7151 skipped
 ... ... @@ -89,4 +89,27 @@ Real lineIntersect(const Point3D &p, const Vector3D &v t *= denominator < 0 ? -1 : 1; return t; } Real haversine(Real lat1, Real lon1, Real lat2, Real lon2) { // Haversine formula Real dlat = toRadians(lat2 - lat1); Real dlon = toRadians(lon2 - lon1); Real haversine_dlat = std::sin(dlat / 2.0); haversine_dlat *= haversine_dlat; Real haversine_dlon = std::sin(dlon / 2.0); haversine_dlon *= haversine_dlon; Real delta_sigma = haversine_dlat + std::cos(toRadians(lat1)) * std::cos(toRadians(lat2)) * haversine_dlon; delta_sigma = 2.0 * std::asin(std::sqrt(delta_sigma)); return delta_sigma; } Real greatCircleDistance(Real lat1, Real lon1, Real lat2, Real lon2, Real radius) { return radius * haversine(lat1, lon2, lat2, lon2); } } // namespace radix
 ... ... @@ -15,6 +15,28 @@ namespace radix { /** * @brief haversine The Haversine formula for calculating great-circle * @param lat1 * @param lon1 * @param lat2 * @param lon2 * @return angle(radians) between two points */ Real haversine(Real lat1, Real lon1, Real lat2, Real lon2); /** * @brief greatCircleDistance Calculates the shortest distance between two points on the surface of a sphere * @param lat1 * @param lon1 * @param lat2 * @param lon2 * @param radius * @return */ Real greatCircleDistance(Real lat1, Real lon1, Real lat2, Real lon2, Real radius); std::vector getEqualAreaRadii( const std::vector& radii, const std::vector& subrings ); inline Real toDegrees( Real radians ) ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!