1 // Boost.Geometry (aka GGL, Generic Geometry Library) 2 3 // Copyright (c) 2012-2020 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_BUFFER_LINE_LINE_INTERSECTION_HPP 10 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_LINE_LINE_INTERSECTION_HPP 11 12 #include <boost/geometry/core/assert.hpp> 13 #include <boost/geometry/arithmetic/infinite_line_functions.hpp> 14 #include <boost/geometry/algorithms/detail/make/make.hpp> 15 16 #include <boost/core/ignore_unused.hpp> 17 18 19 namespace boost { namespace geometry 20 { 21 22 23 #ifndef DOXYGEN_NO_DETAIL 24 namespace detail { namespace buffer 25 { 26 27 // TODO: it might once be changed this to proper strategy 28 struct line_line_intersection 29 { 30 template <typename Point> 31 static inline Point applyboost::geometry::detail::buffer::line_line_intersection32 apply(Point const& pi, Point const& pj, Point const& qi, Point const& qj) 33 { 34 typedef typename coordinate_type<Point>::type ct; 35 typedef model::infinite_line<ct> line_type; 36 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); 39 40 // The input lines are not parallel, they intersect, because 41 // their join type is checked before. 42 Point ip; 43 bool const intersecting = arithmetic::intersection_point(p, q, ip); 44 BOOST_GEOMETRY_ASSERT(intersecting); 45 boost::ignore_unused(intersecting); 46 47 return ip; 48 } 49 }; 50 51 52 }} // namespace detail::buffer 53 #endif // DOXYGEN_NO_DETAIL 54 55 56 }} // namespace boost::geometry 57 58 59 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_LINE_LINE_INTERSECTION_HPP 60