Chris@102
|
1 // Boost.Geometry
|
Chris@102
|
2
|
Chris@102
|
3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
Chris@102
|
4
|
Chris@102
|
5 // This file was modified by Oracle on 2014.
|
Chris@102
|
6 // Modifications copyright (c) 2014 Oracle and/or its affiliates.
|
Chris@102
|
7
|
Chris@102
|
8 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
Chris@102
|
9
|
Chris@102
|
10 // Use, modification and distribution is subject to the Boost Software License,
|
Chris@102
|
11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@102
|
12 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@102
|
13
|
Chris@102
|
14 #ifndef BOOST_GEOMETRY_STRATEGIES_AGNOSTIC_SIDE_BY_AZIMUTH_HPP
|
Chris@102
|
15 #define BOOST_GEOMETRY_STRATEGIES_AGNOSTIC_SIDE_BY_AZIMUTH_HPP
|
Chris@102
|
16
|
Chris@102
|
17 #include <boost/mpl/if.hpp>
|
Chris@102
|
18 #include <boost/type_traits.hpp>
|
Chris@102
|
19 #include <boost/core/ignore_unused.hpp>
|
Chris@102
|
20
|
Chris@102
|
21 #include <boost/geometry/core/cs.hpp>
|
Chris@102
|
22 #include <boost/geometry/core/access.hpp>
|
Chris@102
|
23 #include <boost/geometry/core/radian_access.hpp>
|
Chris@102
|
24
|
Chris@102
|
25 #include <boost/geometry/algorithms/detail/azimuth.hpp>
|
Chris@102
|
26
|
Chris@102
|
27 #include <boost/geometry/util/math.hpp>
|
Chris@102
|
28 #include <boost/geometry/util/promote_floating_point.hpp>
|
Chris@102
|
29 #include <boost/geometry/util/select_calculation_type.hpp>
|
Chris@102
|
30
|
Chris@102
|
31 #include <boost/geometry/strategies/side.hpp>
|
Chris@102
|
32 //#include <boost/geometry/strategies/concepts/side_concept.hpp>
|
Chris@102
|
33
|
Chris@102
|
34
|
Chris@102
|
35 namespace boost { namespace geometry
|
Chris@102
|
36 {
|
Chris@102
|
37
|
Chris@102
|
38
|
Chris@102
|
39 namespace strategy { namespace side
|
Chris@102
|
40 {
|
Chris@102
|
41
|
Chris@102
|
42 /*!
|
Chris@102
|
43 \brief Check at which side of a segment a point lies
|
Chris@102
|
44 left of segment (> 0), right of segment (< 0), on segment (0)
|
Chris@102
|
45 \ingroup strategies
|
Chris@102
|
46 \tparam Model Reference model of coordinate system.
|
Chris@102
|
47 \tparam CalculationType \tparam_calculation
|
Chris@102
|
48 */
|
Chris@102
|
49 template <typename Model, typename CalculationType = void>
|
Chris@102
|
50 class side_by_azimuth
|
Chris@102
|
51 {
|
Chris@102
|
52 public:
|
Chris@102
|
53 side_by_azimuth(Model const& model = Model())
|
Chris@102
|
54 : m_model(model)
|
Chris@102
|
55 {}
|
Chris@102
|
56
|
Chris@102
|
57 template <typename P1, typename P2, typename P>
|
Chris@102
|
58 inline int apply(P1 const& p1, P2 const& p2, P const& p)
|
Chris@102
|
59 {
|
Chris@102
|
60 typedef typename promote_floating_point
|
Chris@102
|
61 <
|
Chris@102
|
62 typename select_calculation_type_alt
|
Chris@102
|
63 <
|
Chris@102
|
64 CalculationType,
|
Chris@102
|
65 P1, P2, P
|
Chris@102
|
66 >::type
|
Chris@102
|
67 >::type calc_t;
|
Chris@102
|
68
|
Chris@102
|
69 calc_t d1 = 0.001;
|
Chris@102
|
70 calc_t crs_AD = geometry::detail::azimuth<calc_t>(p1, p, m_model);
|
Chris@102
|
71 calc_t crs_AB = geometry::detail::azimuth<calc_t>(p1, p2, m_model);
|
Chris@102
|
72 calc_t XTD = asin(sin(d1) * sin(crs_AD - crs_AB));
|
Chris@102
|
73
|
Chris@102
|
74 return math::equals(XTD, 0) ? 0 : XTD < 0 ? 1 : -1;
|
Chris@102
|
75 }
|
Chris@102
|
76
|
Chris@102
|
77 private:
|
Chris@102
|
78 Model m_model;
|
Chris@102
|
79 };
|
Chris@102
|
80
|
Chris@102
|
81 }} // namespace strategy::side
|
Chris@102
|
82
|
Chris@102
|
83
|
Chris@102
|
84 }} // namespace boost::geometry
|
Chris@102
|
85
|
Chris@102
|
86
|
Chris@102
|
87 #endif // BOOST_GEOMETRY_STRATEGIES_AGNOSTIC_SIDE_BY_AZIMUTH_HPP
|