diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2017-09-13 11:08:07 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2017-09-13 11:09:00 +0900 |
commit | b5c87084afaef42b2d058f68091be31988a6a874 (patch) | |
tree | adef9a65870a41181687e11d57fdf98e7629de3c /boost/geometry/util | |
parent | 34bd32e225e2a8a94104489b31c42e5801cc1f4a (diff) | |
download | boost-b5c87084afaef42b2d058f68091be31988a6a874.tar.gz boost-b5c87084afaef42b2d058f68091be31988a6a874.tar.bz2 boost-b5c87084afaef42b2d058f68091be31988a6a874.zip |
Imported Upstream version 1.64.0upstream/1.64.0
Change-Id: Id9212edd016dd55f21172c427aa7894d1d24148b
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'boost/geometry/util')
-rw-r--r-- | boost/geometry/util/math.hpp | 15 | ||||
-rw-r--r-- | boost/geometry/util/normalize_spheroidal_coordinates.hpp | 34 |
2 files changed, 48 insertions, 1 deletions
diff --git a/boost/geometry/util/math.hpp b/boost/geometry/util/math.hpp index 234cfa1ed0..b1c3648c98 100644 --- a/boost/geometry/util/math.hpp +++ b/boost/geometry/util/math.hpp @@ -71,6 +71,19 @@ inline T const& greatest(T const& v1, T const& v2, T const& v3, T const& v4, T c } +template <typename T> +inline T bounded(T const& v, T const& lower, T const& upper) +{ + return (std::min)((std::max)(v, lower), upper); +} + +template <typename T> +inline T bounded(T const& v, T const& lower) +{ + return (std::max)(v, lower); +} + + template <typename T, bool IsFloatingPoint = boost::is_floating_point<T>::value> struct abs @@ -518,7 +531,7 @@ inline T scaled_epsilon(T const& value) } -// Maybe replace this by boost equals or boost ublas numeric equals or so +// Maybe replace this by boost equals or so /*! \brief returns true if both arguments are equal. diff --git a/boost/geometry/util/normalize_spheroidal_coordinates.hpp b/boost/geometry/util/normalize_spheroidal_coordinates.hpp index 377051eef1..19d4d33d28 100644 --- a/boost/geometry/util/normalize_spheroidal_coordinates.hpp +++ b/boost/geometry/util/normalize_spheroidal_coordinates.hpp @@ -282,6 +282,40 @@ inline CoordinateType longitude_distance_unsigned(CoordinateType const& longitud return diff; } +/*! +\brief The abs difference between longitudes in range [0, 180]. +\tparam Units The units of the coordindate system in the spheroid +\tparam CoordinateType The type of the coordinates +\param longitude1 Longitude 1 +\param longitude2 Longitude 2 +\ingroup utility +*/ +template <typename Units, typename CoordinateType> +inline CoordinateType longitude_difference(CoordinateType const& longitude1, + CoordinateType const& longitude2) +{ + return math::abs(math::longitude_distance_signed<Units>(longitude1, longitude2)); +} + +template <typename Units, typename CoordinateType> +inline CoordinateType longitude_interval_distance_signed(CoordinateType const& longitude_a1, + CoordinateType const& longitude_a2, + CoordinateType const& longitude_b) +{ + CoordinateType const c0 = 0; + CoordinateType dist_a12 = longitude_distance_signed<Units>(longitude_a1, longitude_a2); + CoordinateType dist_a1b = longitude_distance_signed<Units>(longitude_a1, longitude_b); + if (dist_a12 < c0) + { + dist_a12 = -dist_a12; + dist_a1b = -dist_a1b; + } + + return dist_a1b < c0 ? dist_a1b + : dist_a1b > dist_a12 ? dist_a1b - dist_a12 + : c0; +} + } // namespace math |