File indexing completed on 2025-01-18 09:36:44
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef BOOST_GEOMETRY_STRATEGY_CARTESIAN_SIDE_ROUNDED_INPUT_HPP
0014 #define BOOST_GEOMETRY_STRATEGY_CARTESIAN_SIDE_ROUNDED_INPUT_HPP
0015
0016 #include <limits>
0017
0018 #include <boost/geometry/core/access.hpp>
0019 #include <boost/geometry/core/config.hpp>
0020
0021 #include <boost/geometry/util/math.hpp>
0022
0023 #include <boost/geometry/strategies/side.hpp>
0024
0025 #include <boost/geometry/util/select_calculation_type.hpp>
0026
0027 namespace boost { namespace geometry
0028 {
0029
0030 namespace strategy { namespace side
0031 {
0032
0033 template <typename CalculationType = void, int Coeff1 = 5, int Coeff2 = 32>
0034 struct side_rounded_input
0035 {
0036 using cs_tag = cartesian_tag;
0037
0038 template <typename P1, typename P2, typename P>
0039 static inline int apply(P1 const& p1, P2 const& p2, P const& p)
0040 {
0041 using coor_t = typename select_calculation_type_alt<CalculationType, P1, P2, P>::type;
0042
0043 coor_t const p1_x = geometry::get<0>(p1);
0044 coor_t const p1_y = geometry::get<1>(p1);
0045 coor_t const p2_x = geometry::get<0>(p2);
0046 coor_t const p2_y = geometry::get<1>(p2);
0047 coor_t const p_x = geometry::get<0>(p);
0048 coor_t const p_y = geometry::get<1>(p);
0049
0050 static coor_t const eps = std::numeric_limits<coor_t>::epsilon() / 2;
0051 coor_t const det = (p1_x - p_x) * (p2_y - p_y) - (p1_y - p_y) * (p2_x - p_x);
0052 coor_t const err_bound = (Coeff1 * eps + Coeff2 * eps * eps) *
0053 ( (geometry::math::abs(p1_x) + geometry::math::abs(p_x))
0054 * (geometry::math::abs(p2_y) + geometry::math::abs(p_y))
0055 + (geometry::math::abs(p2_x) + geometry::math::abs(p_x))
0056 * (geometry::math::abs(p1_y) + geometry::math::abs(p_y)));
0057 return (det > err_bound) - (det < -err_bound);
0058 }
0059 };
0060
0061 }}
0062
0063 }}
0064
0065 #endif