File indexing completed on 2025-01-18 09:35:08
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_APPROXIMATELY_EQUALS_HPP
0010 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_APPROXIMATELY_EQUALS_HPP
0011
0012 #include <boost/geometry/core/access.hpp>
0013 #include <boost/geometry/util/math.hpp>
0014 #include <boost/geometry/util/select_coordinate_type.hpp>
0015 #include <boost/geometry/util/select_most_precise.hpp>
0016
0017 namespace boost { namespace geometry
0018 {
0019
0020 #ifndef DOXYGEN_NO_DETAIL
0021 namespace detail { namespace overlay
0022 {
0023
0024
0025
0026
0027 template <typename T>
0028 struct common_approximately_equals_epsilon_multiplier
0029 {
0030 static T value()
0031 {
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045 return T(100);
0046 }
0047 };
0048
0049 template <typename Point1, typename Point2, typename E>
0050 inline bool approximately_equals(Point1 const& a, Point2 const& b,
0051 E const& epsilon_multiplier)
0052 {
0053 using coor_t = typename select_coordinate_type<Point1, Point2>::type;
0054 using calc_t = typename geometry::select_most_precise<coor_t, E>::type;
0055
0056 calc_t const& a0 = geometry::get<0>(a);
0057 calc_t const& b0 = geometry::get<0>(b);
0058 calc_t const& a1 = geometry::get<1>(a);
0059 calc_t const& b1 = geometry::get<1>(b);
0060
0061 math::detail::equals_factor_policy<calc_t> policy(a0, b0, a1, b1);
0062 policy.multiply_epsilon(epsilon_multiplier);
0063
0064 return math::detail::equals_by_policy(a0, b0, policy)
0065 && math::detail::equals_by_policy(a1, b1, policy);
0066 }
0067
0068 }}
0069 #endif
0070
0071
0072 }}
0073
0074 #endif