Boost::Geometry::Model::Segment
实例
// header 有两种载入方式
// Either: #include <boost/geometry/geometries/geometries.hpp>
// Or: #include <boost/geometry/geometries/segment.hpp>
#include <iostream>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/geometries.hpp>
namespace bg = boost::geometry;
int main()
{
typedef bg::model::point<double, 2, bg::cs::cartesian> point_t;
typedef bg::model::segment<point_t> segment_t;
segment_t seg1;
segment_t seg2(point_t(0.0, 0.0), point_t(5.0, 5.0));
#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX
segment_t seg3{{0.0, 0.0}, {5.0, 5.0}};
#endif
bg::set<0, 0>(seg1, 1.0);
bg::set<0, 1>(seg1, 2.0);
bg::set<1, 0>(seg1, 3.0);
bg::set<1, 1>(seg1, 4.0);
double x0 = bg::get<0, 0>(seg1);
double y0 = bg::get<0, 1>(seg1);
double x1 = bg::get<1, 0>(seg1);
double y1 = bg::get<1, 1>(seg1);
std::cout << x0 << ", " << y0 << ", " << x1 << ", " << y1 << std::endl;
return 0;
}