]>
Commit | Line | Data |
---|---|---|
1e59de90 TL |
1 | // Boost.Geometry (aka GGL, Generic Geometry Library) |
2 | ||
3 | // Copyright (c) 2021 Barend Gehrels, Amsterdam, the Netherlands. | |
4 | ||
5 | // Use, modification and distribution is subject to the Boost Software License, | |
6 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
7 | // http://www.boost.org/LICENSE_1_0.txt) | |
8 | ||
9 | #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_APPROXIMATELY_EQUALS_HPP | |
10 | #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_APPROXIMATELY_EQUALS_HPP | |
11 | ||
12 | #include <boost/geometry/core/access.hpp> | |
13 | #include <boost/geometry/util/math.hpp> | |
14 | #include <boost/geometry/util/select_coordinate_type.hpp> | |
15 | #include <boost/geometry/util/select_most_precise.hpp> | |
16 | ||
17 | namespace boost { namespace geometry | |
18 | { | |
19 | ||
20 | #ifndef DOXYGEN_NO_DETAIL | |
21 | namespace detail { namespace overlay | |
22 | { | |
23 | ||
24 | template <typename Point1, typename Point2, typename E> | |
25 | inline bool approximately_equals(Point1 const& a, Point2 const& b, | |
26 | E const& epsilon_multiplier) | |
27 | { | |
28 | using coor_t = typename select_coordinate_type<Point1, Point2>::type; | |
29 | using calc_t = typename geometry::select_most_precise<coor_t, E>::type; | |
30 | ||
31 | calc_t const& a0 = geometry::get<0>(a); | |
32 | calc_t const& b0 = geometry::get<0>(b); | |
33 | calc_t const& a1 = geometry::get<1>(a); | |
34 | calc_t const& b1 = geometry::get<1>(b); | |
35 | ||
36 | math::detail::equals_factor_policy<calc_t> policy(a0, b0, a1, b1); | |
37 | policy.multiply_epsilon(epsilon_multiplier); | |
38 | ||
39 | return math::detail::equals_by_policy(a0, b0, policy) | |
40 | && math::detail::equals_by_policy(a1, b1, policy); | |
41 | } | |
42 | ||
43 | }} // namespace detail::overlay | |
44 | #endif //DOXYGEN_NO_DETAIL | |
45 | ||
46 | ||
47 | }} // namespace boost::geometry | |
48 | ||
49 | #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_APPROXIMATELY_EQUALS_HPP |