diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2019-12-05 15:22:41 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2019-12-05 15:22:41 +0900 |
commit | 3c1df2168531ad5580076ae08d529054689aeedd (patch) | |
tree | 941aff6f86393eecacddfec252a8508c7e8351c9 /boost/geometry/formulas | |
parent | d6a306e745acfee00e81ccaf3324a2a03516db41 (diff) | |
download | boost-3c1df2168531ad5580076ae08d529054689aeedd.tar.gz boost-3c1df2168531ad5580076ae08d529054689aeedd.tar.bz2 boost-3c1df2168531ad5580076ae08d529054689aeedd.zip |
Imported Upstream version 1.70.0upstream/1.70.0
Diffstat (limited to 'boost/geometry/formulas')
-rw-r--r-- | boost/geometry/formulas/area_formulas.hpp | 1 | ||||
-rw-r--r-- | boost/geometry/formulas/differential_quantities.hpp | 7 | ||||
-rw-r--r-- | boost/geometry/formulas/eccentricity_sqr.hpp | 6 | ||||
-rw-r--r-- | boost/geometry/formulas/interpolate_point_spherical.hpp | 107 | ||||
-rw-r--r-- | boost/geometry/formulas/karney_direct.hpp | 25 | ||||
-rw-r--r-- | boost/geometry/formulas/meridian_direct.hpp | 10 | ||||
-rw-r--r-- | boost/geometry/formulas/meridian_segment.hpp | 4 | ||||
-rw-r--r-- | boost/geometry/formulas/quarter_meridian.hpp | 7 | ||||
-rw-r--r-- | boost/geometry/formulas/spherical.hpp | 6 | ||||
-rw-r--r-- | boost/geometry/formulas/thomas_direct.hpp | 7 | ||||
-rw-r--r-- | boost/geometry/formulas/vincenty_direct.hpp | 7 |
11 files changed, 145 insertions, 42 deletions
diff --git a/boost/geometry/formulas/area_formulas.hpp b/boost/geometry/formulas/area_formulas.hpp index 66d90a7256..c670f831a6 100644 --- a/boost/geometry/formulas/area_formulas.hpp +++ b/boost/geometry/formulas/area_formulas.hpp @@ -12,6 +12,7 @@ #ifndef BOOST_GEOMETRY_FORMULAS_AREA_FORMULAS_HPP #define BOOST_GEOMETRY_FORMULAS_AREA_FORMULAS_HPP +#include <boost/geometry/core/radian_access.hpp> #include <boost/geometry/formulas/flattening.hpp> #include <boost/geometry/util/math.hpp> #include <boost/math/special_functions/hypot.hpp> diff --git a/boost/geometry/formulas/differential_quantities.hpp b/boost/geometry/formulas/differential_quantities.hpp index ff2ec539db..6d4c223286 100644 --- a/boost/geometry/formulas/differential_quantities.hpp +++ b/boost/geometry/formulas/differential_quantities.hpp @@ -1,6 +1,6 @@ // Boost.Geometry -// Copyright (c) 2016-2017 Oracle and/or its affiliates. +// Copyright (c) 2016-2019 Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -70,10 +70,11 @@ public: // equator if (math::equals(sin_bet1, c0) && math::equals(sin_bet2, c0)) { - CT const sig_12 = math::abs(dlon) / one_minus_f; + CT const sig_12 = dlon / one_minus_f; if (BOOST_GEOMETRY_CONDITION(EnableReducedLength)) { - CT m12 = sin(sig_12) * b; + int azi_sign = math::sign(azimuth) >= 0 ? 1 : -1; // for antipodal + CT m12 = azi_sign * sin(sig_12) * b; reduced_length = m12; } diff --git a/boost/geometry/formulas/eccentricity_sqr.hpp b/boost/geometry/formulas/eccentricity_sqr.hpp index 01a9beacb9..1608a85707 100644 --- a/boost/geometry/formulas/eccentricity_sqr.hpp +++ b/boost/geometry/formulas/eccentricity_sqr.hpp @@ -1,6 +1,6 @@ // Boost.Geometry -// Copyright (c) 2016 Oracle and/or its affiliates. +// Copyright (c) 2016, 2018 Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -11,11 +11,13 @@ #ifndef BOOST_GEOMETRY_FORMULAS_ECCENCRICITY_SQR_HPP #define BOOST_GEOMETRY_FORMULAS_ECCENCRICITY_SQR_HPP +#include <boost/geometry/algorithms/not_implemented.hpp> + #include <boost/geometry/core/radius.hpp> #include <boost/geometry/core/tag.hpp> #include <boost/geometry/core/tags.hpp> -#include <boost/geometry/algorithms/not_implemented.hpp> +#include <boost/geometry/util/math.hpp> namespace boost { namespace geometry { diff --git a/boost/geometry/formulas/interpolate_point_spherical.hpp b/boost/geometry/formulas/interpolate_point_spherical.hpp new file mode 100644 index 0000000000..7141a5a9f6 --- /dev/null +++ b/boost/geometry/formulas/interpolate_point_spherical.hpp @@ -0,0 +1,107 @@ +// Boost.Geometry + +// Copyright (c) 2019 Oracle and/or its affiliates. + +// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_FORMULAS_INTERPOLATE_POINT_SPHERICAL_HPP +#define BOOST_GEOMETRY_FORMULAS_INTERPOLATE_POINT_SPHERICAL_HPP + +namespace boost { namespace geometry { namespace formula +{ + +template <typename CalculationType> +class interpolate_point_spherical +{ + typedef model::point<CalculationType, 3, cs::cartesian> point3d_t; + +public : + + template <typename Point> + void compute_angle(Point const& p0, + Point const& p1, + CalculationType& angle01) + { + m_xyz0 = formula::sph_to_cart3d<point3d_t>(p0); + m_xyz1 = formula::sph_to_cart3d<point3d_t>(p1); + CalculationType const dot01 = geometry::dot_product(m_xyz0, m_xyz1); + angle01 = acos(dot01); + } + + template <typename Point> + void compute_axis(Point const& p0, + CalculationType const& angle01) + { + CalculationType const c0 = 0, c1 = 1; + CalculationType const pi = math::pi<CalculationType>(); + + if (! math::equals(angle01, pi)) + { + m_axis = geometry::cross_product(m_xyz0, m_xyz1); + geometry::detail::vec_normalize(m_axis); + } + else // antipodal + { + CalculationType const half_pi = math::half_pi<CalculationType>(); + CalculationType const lat = geometry::get_as_radian<1>(p0); + + if (math::equals(lat, half_pi)) + { + // pointing east, segment lies on prime meridian, going south + m_axis = point3d_t(c0, c1, c0); + } + else if (math::equals(lat, -half_pi)) + { + // pointing west, segment lies on prime meridian, going north + m_axis = point3d_t(c0, -c1, c0); + } + else + { + // lon rotated west by pi/2 at equator + CalculationType const lon = geometry::get_as_radian<0>(p0); + m_axis = point3d_t(sin(lon), -cos(lon), c0); + } + } + } + + template <typename Point> + void compute_point(CalculationType const& a, Point& p) + { + CalculationType const c1 = 1; + + // Axis-Angle rotation + // see: https://en.wikipedia.org/wiki/Axis-angle_representation + CalculationType const cos_a = cos(a); + CalculationType const sin_a = sin(a); + // cos_a * v + point3d_t s1 = m_xyz0; + geometry::multiply_value(s1, cos_a); + // sin_a * (n x v) + point3d_t s2 = geometry::cross_product(m_axis, m_xyz0); + geometry::multiply_value(s2, sin_a); + // (1 - cos_a)(n.v) * n + point3d_t s3 = m_axis; + geometry::multiply_value(s3, (c1 - cos_a) * + geometry::dot_product(m_axis, m_xyz0)); + // v_rot = cos_a * v + sin_a * (n x v) + (1 - cos_a)(n.v) * e + point3d_t v_rot = s1; + geometry::add_point(v_rot, s2); + geometry::add_point(v_rot, s3); + + p = formula::cart3d_to_sph<Point>(v_rot); + } + +private : + point3d_t m_xyz0; + point3d_t m_xyz1; + point3d_t m_axis; +}; + +}}} // namespace boost::geometry::formula + +#endif // BOOST_GEOMETRY_FORMULAS_INTERPOLATE_POINT_SPHERICAL_HPP diff --git a/boost/geometry/formulas/karney_direct.hpp b/boost/geometry/formulas/karney_direct.hpp index 1e6add7d49..7a89061fd6 100644 --- a/boost/geometry/formulas/karney_direct.hpp +++ b/boost/geometry/formulas/karney_direct.hpp @@ -2,7 +2,12 @@ // Copyright (c) 2018 Adeel Ahmad, Islamabad, Pakistan. -// Contributed and/or modified by Adeel Ahmad, as part of Google Summer of Code 2018 program. +// Contributed and/or modified by Adeel Ahmad, +// as part of Google Summer of Code 2018 program. + +// This file was modified by Oracle on 2018. +// Modifications copyright (c) 2018 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, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -30,13 +35,14 @@ #include <boost/math/constants/constants.hpp> #include <boost/math/special_functions/hypot.hpp> -#include <boost/geometry/util/math.hpp> -#include <boost/geometry/util/series_expansion.hpp> -#include <boost/geometry/util/normalize_spheroidal_coordinates.hpp> - #include <boost/geometry/formulas/flattening.hpp> #include <boost/geometry/formulas/result_direct.hpp> +#include <boost/geometry/util/condition.hpp> +#include <boost/geometry/util/math.hpp> +#include <boost/geometry/util/normalize_spheroidal_coordinates.hpp> +#include <boost/geometry/util/series_expansion.hpp> + namespace boost { namespace geometry { namespace formula { @@ -82,15 +88,6 @@ public: Azi azi12 = azimuth12; math::normalize_azimuth<degree, Azi>(azi12); - Dist const dist_c0 = 0; - - if (math::equals(distance, dist_c0) || distance < dist_c0) - { - result.lon2 = lon1; - result.lat2 = lat1; - return result; - } - CT const c0 = 0; CT const c1 = 1; CT const c2 = 2; diff --git a/boost/geometry/formulas/meridian_direct.hpp b/boost/geometry/formulas/meridian_direct.hpp index e55b35e88f..f8e73f57c6 100644 --- a/boost/geometry/formulas/meridian_direct.hpp +++ b/boost/geometry/formulas/meridian_direct.hpp @@ -3,6 +3,7 @@ // Copyright (c) 2018 Oracle and/or its affiliates. // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -15,14 +16,15 @@ #include <boost/geometry/core/radius.hpp> -#include <boost/geometry/util/condition.hpp> -#include <boost/geometry/util/math.hpp> - -#include <boost/geometry/formulas/meridian_inverse.hpp> +#include <boost/geometry/formulas/differential_quantities.hpp> #include <boost/geometry/formulas/flattening.hpp> +#include <boost/geometry/formulas/meridian_inverse.hpp> #include <boost/geometry/formulas/quarter_meridian.hpp> #include <boost/geometry/formulas/result_direct.hpp> +#include <boost/geometry/util/condition.hpp> +#include <boost/geometry/util/math.hpp> + namespace boost { namespace geometry { namespace formula { diff --git a/boost/geometry/formulas/meridian_segment.hpp b/boost/geometry/formulas/meridian_segment.hpp index 535e31e3db..0aa7542f91 100644 --- a/boost/geometry/formulas/meridian_segment.hpp +++ b/boost/geometry/formulas/meridian_segment.hpp @@ -1,8 +1,9 @@ // Boost.Geometry -// Copyright (c) 2017 Oracle and/or its affiliates. +// Copyright (c) 2017-2018 Oracle and/or its affiliates. // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -14,7 +15,6 @@ #include <boost/math/constants/constants.hpp> #include <boost/geometry/core/radius.hpp> -#include <boost/geometry/srs/srs.hpp> #include <boost/geometry/util/condition.hpp> #include <boost/geometry/util/math.hpp> diff --git a/boost/geometry/formulas/quarter_meridian.hpp b/boost/geometry/formulas/quarter_meridian.hpp index 2f93f53cf6..5aa10cc870 100644 --- a/boost/geometry/formulas/quarter_meridian.hpp +++ b/boost/geometry/formulas/quarter_meridian.hpp @@ -3,6 +3,7 @@ // Copyright (c) 2018 Oracle and/or its affiliates. // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -11,11 +12,15 @@ #ifndef BOOST_GEOMETRY_FORMULAS_QUARTER_MERIDIAN_HPP #define BOOST_GEOMETRY_FORMULAS_QUARTER_MERIDIAN_HPP +#include <boost/geometry/algorithms/not_implemented.hpp> + #include <boost/geometry/core/radius.hpp> #include <boost/geometry/core/tag.hpp> #include <boost/geometry/core/tags.hpp> -#include <boost/geometry/algorithms/not_implemented.hpp> +#include <boost/geometry/formulas/flattening.hpp> + +#include <boost/geometry/util/math.hpp> namespace boost { namespace geometry { diff --git a/boost/geometry/formulas/spherical.hpp b/boost/geometry/formulas/spherical.hpp index 5599cd6e81..964e2de302 100644 --- a/boost/geometry/formulas/spherical.hpp +++ b/boost/geometry/formulas/spherical.hpp @@ -13,6 +13,7 @@ #include <boost/geometry/core/coordinate_system.hpp> #include <boost/geometry/core/coordinate_type.hpp> +#include <boost/geometry/core/cs.hpp> #include <boost/geometry/core/access.hpp> #include <boost/geometry/core/radian_access.hpp> #include <boost/geometry/core/radius.hpp> @@ -98,7 +99,7 @@ static inline PointSph cart3d_to_sph(Point3d const& point_3d) math::normalize_spheroidal_coordinates < - typename coordinate_system<PointSph>::type::units, + typename detail::cs_angular_units<PointSph>::type, coord_t >(lon, lat); @@ -183,6 +184,7 @@ inline T spherical_azimuth(T const& lon1, T const& lat1, T const& lon2, T const& template <typename T> inline int azimuth_side_value(T const& azi_a1_p, T const& azi_a1_a2) { + T const c0 = 0; T const pi = math::pi<T>(); T const two_pi = math::two_pi<T>(); @@ -213,7 +215,7 @@ inline int azimuth_side_value(T const& azi_a1_p, T const& azi_a1_a2) // the difference to 0 as well // positive azimuth is on the right side - return math::equals(a_diff, 0) + return math::equals(a_diff, c0) || math::equals(a_diff, pi) || math::equals(a_diff, -pi) ? 0 : a_diff > 0 ? -1 // right diff --git a/boost/geometry/formulas/thomas_direct.hpp b/boost/geometry/formulas/thomas_direct.hpp index 830f256a6e..7b61616af6 100644 --- a/boost/geometry/formulas/thomas_direct.hpp +++ b/boost/geometry/formulas/thomas_direct.hpp @@ -67,13 +67,6 @@ public: CT const lon1 = lo1; CT const lat1 = la1; - if ( math::equals(distance, Dist(0)) || distance < Dist(0) ) - { - result.lon2 = lon1; - result.lat2 = lat1; - return result; - } - CT const c0 = 0; CT const c1 = 1; CT const c2 = 2; diff --git a/boost/geometry/formulas/vincenty_direct.hpp b/boost/geometry/formulas/vincenty_direct.hpp index b72379defe..2806de04cd 100644 --- a/boost/geometry/formulas/vincenty_direct.hpp +++ b/boost/geometry/formulas/vincenty_direct.hpp @@ -74,13 +74,6 @@ public: CT const lon1 = lo1; CT const lat1 = la1; - if ( math::equals(distance, Dist(0)) || distance < Dist(0) ) - { - result.lon2 = lon1; - result.lat2 = lat1; - return result; - } - CT const radius_a = CT(get_radius<0>(spheroid)); CT const radius_b = CT(get_radius<2>(spheroid)); CT const flattening = formula::flattening<CT>(spheroid); |