1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2012-2019 Barend Gehrels, Amsterdam, the Netherlands.
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)
9 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_LINE_LINE_INTERSECTION_HPP
10 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_LINE_LINE_INTERSECTION_HPP
13 #include <boost/geometry/arithmetic/infinite_line_functions.hpp>
14 #include <boost/geometry/algorithms/detail/make/make.hpp>
15 #include <boost/geometry/strategies/buffer.hpp>
17 namespace boost { namespace geometry
21 #ifndef DOXYGEN_NO_DETAIL
22 namespace detail { namespace buffer
25 // TODO: it might once be changed this to proper strategy
26 struct line_line_intersection
28 template <typename Point>
29 static inline strategy::buffer::join_selector
30 apply(Point const& pi, Point const& pj,
31 Point const& qi, Point const& qj,
34 typedef typename coordinate_type<Point>::type ct;
35 typedef model::infinite_line<ct> line_type;
37 line_type const p = detail::make::make_infinite_line<ct>(pi, pj);
38 line_type const q = detail::make::make_infinite_line<ct>(qi, qj);
40 if (arithmetic::intersection_point(p, q, ip))
42 return strategy::buffer::join_convex;
45 // The lines do not intersect.
46 // Distinguish between continuing lines (having a similar direction)
47 // and spikes (having the opposite direction).
48 return arithmetic::similar_direction(p, q)
49 ? strategy::buffer::join_continue
50 : strategy::buffer::join_spike
56 }} // namespace detail::buffer
57 #endif // DOXYGEN_NO_DETAIL
60 }} // namespace boost::geometry
63 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_LINE_LINE_INTERSECTION_HPP