]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/doc/src/examples/algorithms/intersection_segment.cpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
4 // Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
6 // Use, modification and distribution is subject to the Boost Software License,
7 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
10 //[intersection_segment
11 //` Calculate the intersection point (or points) of two segments
15 #include <boost/geometry.hpp>
16 #include <boost/geometry/geometries/point_xy.hpp>
18 #include <boost/foreach.hpp>
23 typedef boost::geometry::model::d2::point_xy
<double> P
;
24 boost::geometry::model::segment
<P
> segment1
, segment2
;
25 boost::geometry::read_wkt("linestring(1 1,2 2)", segment1
);
26 boost::geometry::read_wkt("linestring(2 1,1 2)", segment2
);
28 std::vector
<P
> intersections
;
29 boost::geometry::intersection(segment1
, segment2
, intersections
);
31 BOOST_FOREACH(P
const& p
, intersections
)
33 std::cout
<< " " << boost::geometry::wkt(p
);
35 std::cout
<< std::endl
;
43 //[intersection_segment_output