diff options
Diffstat (limited to 'boost/geometry/formulas/sjoberg_intersection.hpp')
-rw-r--r-- | boost/geometry/formulas/sjoberg_intersection.hpp | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/boost/geometry/formulas/sjoberg_intersection.hpp b/boost/geometry/formulas/sjoberg_intersection.hpp index 12abb76757..af56f285f4 100644 --- a/boost/geometry/formulas/sjoberg_intersection.hpp +++ b/boost/geometry/formulas/sjoberg_intersection.hpp @@ -1,7 +1,8 @@ // Boost.Geometry -// Copyright (c) 2016-2019 Oracle and/or its affiliates. +// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2016-2019 Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Use, modification and distribution is subject to the Boost Software License, @@ -71,7 +72,7 @@ struct sjoberg_intersection_spherical_02 CT const tan_lat_a2 = tan(lat_a2); CT const tan_lat_b2 = tan(lat_b2); - + return apply(lon1, lon_a2, lon2, lon_b2, sin_lon1, cos_lon1, sin_lat1, cos_lat1, sin_lon2, cos_lon2, sin_lat2, cos_lat2, @@ -103,7 +104,7 @@ private: CT const tan_alpha1_x = cos_lat1 * tan_lat_a2 - sin_lat1 * cos_dlon1; CT const tan_alpha2_x = cos_lat2 * tan_lat_b2 - sin_lat2 * cos_dlon2; - + CT const c0 = 0; bool const is_vertical1 = math::equals(sin_dlon1, c0) || math::equals(tan_alpha1_x, c0); bool const is_vertical2 = math::equals(sin_dlon2, c0) || math::equals(tan_alpha2_x, c0); @@ -132,7 +133,7 @@ private: { tan_alpha1 = sin_dlon1 / tan_alpha1_x; tan_alpha2 = sin_dlon2 / tan_alpha2_x; - + CT const T1 = tan_alpha1 * cos_lat1; CT const T2 = tan_alpha2 * cos_lat2; CT const T1T2 = T1*T2; @@ -152,12 +153,12 @@ private: CT const lon_dist2 = (std::max)((std::min)(math::longitude_difference<radian>(lon1, lon_2), math::longitude_difference<radian>(lon_a2, lon_2)), (std::min)(math::longitude_difference<radian>(lon2, lon_2), - math::longitude_difference<radian>(lon_b2, lon_2))); + math::longitude_difference<radian>(lon_b2, lon_2))); if (lon_dist2 < lon_dist1) { lon = lon_2; } - + CT const sin_lon = sin(lon); CT const cos_lon = cos(lon); @@ -177,7 +178,7 @@ private: CT const lat_x_2 = tan_alpha2 * cos_lat2; tan_lat = lat_y_2 / lat_x_2; } - + return true; } }; @@ -206,19 +207,19 @@ inline CT sjoberg_d_lambda_e_sqr(CT const& sin_betaj, CT const& sin_beta, { using math::detail::bounded; - if (Order == 0) + if (BOOST_GEOMETRY_CONDITION(Order == 0)) { return 0; } CT const c1 = 1; CT const c2 = 2; - + CT const asin_B = asin(bounded(sin_beta / sqrt_1_Cj_sqr, -c1, c1)); CT const asin_Bj = asin(sin_betaj / sqrt_1_Cj_sqr); CT const L0 = (asin_B - asin_Bj) / c2; - if (Order == 1) + if (BOOST_GEOMETRY_CONDITION(Order == 1)) { return -Cj * e_sqr * L0; } @@ -237,7 +238,7 @@ inline CT sjoberg_d_lambda_e_sqr(CT const& sin_betaj, CT const& sin_beta, CT const sqrt_Yj = math::sqrt(-Xj_sqr + one_minus_Cj_sqr); CT const L1 = (Cj_sqr_plus_one * (asin_B - asin_Bj) + X * sqrt_Y - Xj * sqrt_Yj) / c16; - if (Order == 2) + if (BOOST_GEOMETRY_CONDITION(Order == 2)) { return -Cj * e_sqr * (L0 + e_sqr * L1); } @@ -251,7 +252,7 @@ inline CT sjoberg_d_lambda_e_sqr(CT const& sin_betaj, CT const& sin_beta, CT const Fj = Xj * (-c2 * Xj_sqr + c3 * Cj_sqr + c5); CT const L2 = (E * (asin_B - asin_Bj) + F * sqrt_Y - Fj * sqrt_Yj) / c128; - if (Order == 3) + if (BOOST_GEOMETRY_CONDITION(Order == 3)) { return -Cj * e_sqr * (L0 + e_sqr * (L1 + e_sqr * L2)); } @@ -405,7 +406,7 @@ public: { return false; } - + // NOTE: beta may be slightly out of bounds here but d_lambda handles that CT const dLj = d_lambda(sin_beta); delta_k = sign_lon_diff * (/*asin_t_t0j*/ - asin_tj_t0j + dLj); @@ -451,7 +452,7 @@ public: delta_k_behind = sign_lon_diff * pi; return true; } - + // beta out of bounds and not close if (check_sin_beta && ! (is_sin_beta_ok(sin_beta) @@ -459,7 +460,7 @@ public: { return false; } - + // NOTE: beta may be slightly out of bounds here but d_lambda handles that CT const dLj = d_lambda(sin_beta); delta_k_before = sign_lon_diff * (/*asin_t_t0j*/ - asin_tj_t0j + dLj); @@ -768,7 +769,7 @@ public: } t = one_minus_f * tan_lat_sph; // tan(beta) - } + } // TODO: no need to calculate atan here if reduced latitudes were used // instead of latitudes above, in sjoberg_intersection_spherical_02 @@ -802,7 +803,7 @@ private: CT const c1 = 1; CT const e_sqr = geod1.e_sqr; - + CT lon1_diff = 0; CT lon2_diff = 0; @@ -892,7 +893,7 @@ private: if (math::equals(dbeta_denom, c0)) { return false; - } + } // The sign of dbeta is changed WRT [Sjoberg02] CT const dbeta = (lon1_minus_lon2 + lon1_diff - lon2_diff) / dbeta_denom; @@ -1027,7 +1028,7 @@ private: { break; } - + bool try_t2 = false; converge_07_result result_curr; if (converge_07_step_one(CT(sin(beta1)), t1, lon1_minus_lon2, geodesics, lon_sph, result_curr)) @@ -1063,7 +1064,7 @@ private: } } - + if (try_t2) { CT t2 = t; @@ -1156,7 +1157,7 @@ private: { using math::detail::bounded; CT const c1 = 1; - + CT k_diff_before = 0; CT k_diff_behind = 0; |