]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/boost/geometry/util/normalize_spheroidal_coordinates.hpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / boost / geometry / util / normalize_spheroidal_coordinates.hpp
index 785e52a0de55f78edd79fb38b21f41245d2a6a1c..e595f6c2c08dc3bb0454a32e8073551d5fb1e6b7 100644 (file)
@@ -2,10 +2,11 @@
 
 // Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland.
 
-// Copyright (c) 2015-2017, Oracle and/or its affiliates.
+// Copyright (c) 2015-2020, Oracle and/or its affiliates.
 
 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
+// Contributed and/or modified by Adeel Ahmad, as part of Google Summer of Code 2018 program
 
 // Licensed under the Boost Software License version 1.0.
 // http://www.boost.org/users/license.html
@@ -313,6 +314,31 @@ public:
 };
 
 
+template <typename Units, typename CoordinateType>
+inline void normalize_angle_loop(CoordinateType& angle)
+{
+    typedef constants_on_spheroid<CoordinateType, Units> constants;
+    CoordinateType const pi = constants::half_period();
+    CoordinateType const two_pi = constants::period();
+    while (angle > pi)
+        angle -= two_pi;
+    while (angle <= -pi)
+        angle += two_pi;
+}
+
+template <typename Units, typename CoordinateType>
+inline void normalize_angle_cond(CoordinateType& angle)
+{
+    typedef constants_on_spheroid<CoordinateType, Units> constants;
+    CoordinateType const pi = constants::half_period();
+    CoordinateType const two_pi = constants::period();
+    if (angle > pi)
+        angle -= two_pi;
+    else if (angle <= -pi)
+        angle += two_pi;
+}
+
+
 } // namespace detail
 #endif // DOXYGEN_NO_DETAIL
 
@@ -363,6 +389,37 @@ inline void normalize_longitude(CoordinateType& longitude)
         >::apply(longitude);
 }
 
+/*!
+\brief Short utility to normalize the azimuth on a spheroid
+       in the range (-180, 180].
+\tparam Units The units of the coordindate system in the spheroid
+\tparam CoordinateType The type of the coordinates
+\param angle Angle
+\ingroup utility
+*/
+template <typename Units, typename CoordinateType>
+inline void normalize_azimuth(CoordinateType& angle)
+{
+    normalize_longitude<Units, CoordinateType>(angle);
+}
+
+/*!
+\brief Normalize the given values.
+\tparam ValueType The type of the values
+\param x Value x
+\param y Value y
+TODO: adl1995 - Merge this function with
+formulas/vertex_longitude.hpp
+*/
+template<typename ValueType>
+inline void normalize_unit_vector(ValueType& x, ValueType& y)
+{
+    ValueType h = boost::math::hypot(x, y);
+
+    BOOST_GEOMETRY_ASSERT(h > 0);
+
+    x /= h; y /= h;
+}
 
 /*!
 \brief Short utility to calculate difference between two longitudes