1 | #include <iostream>
|
---|
2 | #include <boost/geometry.hpp>
|
---|
3 | #include <boost/geometry/geometries/point_xy.hpp>
|
---|
4 |
|
---|
5 | using point_t = boost::geometry::model::d2::point_xy<double>;
|
---|
6 | using segment_t = boost::geometry::model::segment<point_t>;
|
---|
7 |
|
---|
8 | int main() {
|
---|
9 | segment_t e1{point_t{100, 350}, point_t{-100, 400}};
|
---|
10 | segment_t e2{point_t{0, 0}, point_t{90, 600}};
|
---|
11 | std::vector<point_t> iv;
|
---|
12 | boost::geometry::intersection(e1, e2, iv);
|
---|
13 | assert(iv.size() == 1);
|
---|
14 | const auto& v = iv[0];
|
---|
15 | bool is_within = boost::geometry::within(v, e1);
|
---|
16 | std::cout << "is within? " << is_within << std::endl;
|
---|
17 | is_within = boost::geometry::within(v, e2);
|
---|
18 | std::cout << "is within? " << is_within << std::endl;
|
---|
19 |
|
---|
20 | return 0;
|
---|
21 | }
|
---|